1. First embodiment replaced by a default packaged as war jar, jar is opened pom modified war
2. Add the following dependencies in pom.xml file
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-tomcat</artifactId>
<scope>provided</scope>
</dependency>
3. Change the code in the startup class DemoApplication (Add Inherited SpringBootServletInitializer, and override the configure method)
@SpringBootApplication
public class DemoApplication extends SpringBootServletInitializer {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder application){
System.out.println("外部tomcat,chapter启动!");
return application.sources(DemoApplication.class);
}
}
二、打包发布和测试。
遇到的问题:
1、部署部成功,网上找原因说是由于jar包的问题,各种排查也无法解决。
最终升级了springboot的版本为2.2.2,问题得以解决。