1. 添加依赖
<dependency>
<groupId>org.apache.tomcat.embed</groupId>
<artifactId>tomcat-embed-jasper</artifactId>
<scope>provided</scope>
</dependency>
说明:尽在编译和测试时使用,打包时排除掉
2.重写配置方法
@SpringBootApplication(exclude= {DataSourceAutoConfiguration.class})标签:tomcat,args,idea,外置,TestApplication,class From: https://www.cnblogs.com/caoaman/p/17160345.html
public class TestApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(TestApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder){
return builder.sources(TestApplication.class);
}