出现这个错的原因是在部署项目的时候,项目中含有websocket的@ServerEndpoint注解的时候,如果项目是springboot项目,去除内置tomcat的时候会把websocket的包也给删除掉,所以需要手动加上.加上这个包,然后再打war包,部署到linux的tomcat下就没问题了.
<!--去除内嵌tomcat-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.tomcat.embed/tomcat-embed-websocket -->
<!--websocket依赖包-->
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-websocket</artifactId>
<version>8.5.23</version>
</dependency>
如果打包就报错的话,把pom里的test依赖删掉,把测试类也删掉
或者在测试类里加个这东西就可以了