修改pom文件
1.将打包方式改成war包
jar改成war2.添加spring-boot-starter-tomcat依赖,把scope设置为provided
spring-boot-starter-tomcat修改启动类
@SpringBootApplication
public class TestTomcatApplication extends SpringBootServletInitializer {
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
return application.sources(TestTomcatApplication.class);
}
public static void main(String[] args) {
SpringApplication.run(TestTomcatApplication.class, args);
}
}
还有一个注意事项:
如果像这样写有几个配置文件:
几个配置文件如果application.yml这个文件是空的时候启动会报错
网友评论