放在tomcat中进行启动
(使用SpringBoot启动时都用的内置插件启动,简单的说就是jar包启动,但是难免有需求)
1. 剔除内置tomcat插件
修改这个spring-boot-starter-web这个依赖配置信息
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
</exclusion>
</exclusions>
</dependency>
2. 引入Servlet依赖jar包
<dependency>
<!--因为内置tomcat已经移除,所以Servlet包也一并移除了-->
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<scope>provided</scope>
</dependency>
3. 修改maven打包方式
<groupId>com.xinbitiangao</groupId>
<artifactId>springbootwar</artifactId>
<version>0.0.1-SNAPSHOT</version>
<!--改成war方式-->
<packaging>war</packaging>
<name>springbootwar</name>
<description></description>
4. 修改主启动类
@SpringBootApplication
//继承SpringBootServletInitializer 这个类即可
public class SpringbootwarApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(SpringbootwarApplication.class, args);
}
}