我用的SpringBoot版本
parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.2</version>
<relativePath/> <!-- lookup parent from repository -->
/parent>
- 修改
pom.xml
文件
<packaging>war</packaging>
修改依赖
<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>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<!--tomcat范围改成provided,告诉它,已经有外部tomcat了,不需要一起打包带走了-->
<scope>provided</scope>
</dependency>
- 修改启动类,继承
SpringBootServletInitializer
,并重写configure
方法
public class JavaTestApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(JavaTestApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return builder.sources(JavaTestApplication.class);
}
}
- 启动项配置
参考链接:https://blog.csdn.net/u012939253/article/details/105530682