web模块下的pom文件
1.替换打包方式
<!--<packaging>jar</packaging>-->
<packaging>war</packaging>
2.如果引用第三方jar包,打入webResources(选做)
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>3.1.0</version>
<configuration>
<webResources>
<webResource>
<directory>${pom.basedir}/src/main/resources/lib/</directory>
<targetPath>WEB-INF/lib/</targetPath>
<includes>
<include>**/*.jar</include>
</includes>
</webResource>
</webResources>
<failOnMissingWebXml>false</failOnMissingWebXml>
<warName>${project.artifactId}</warName>
</configuration>
</plugin>
framework下的pom文件
3.排除jar包中的内置tomcat
<!-- SpringBoot Web容器 -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<!-- war包发布 -->
<!-- 排除jar包中的内置tomcat-->
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
4.WebSocket需要的API
<!-- 排除jar包中的内置tomcat,WebSocket需要的API-->
<dependency>
<groupId>javax.websocket</groupId>
<artifactId>javax.websocket-api</artifactId>
<version>1.1</version>
<scope>provided</scope>
</dependency>
ServerEndpointExporter交由Tomcat管理
注释ServerEndpointExporter
package com.huida.framework.websocket;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.socket.server.standard.ServerEndpointExporter;
/**
* websocket 配置
*
* @author huida
*/
//@Configuration
//public class WebSocketConfig
//{
// @Bean
// public ServerEndpointExporter serverEndpointExporter()
// {
// return new ServerEndpointExporter();
// }
//}