1. Remove Springboot dependent embedded Tomcat
1 <dependency> 2 <groupId>org.springframework.boot</groupId> 3 <artifactId>spring-boot-starter-web</artifactId> 4 <exclusions> 5 <!-- 去除内嵌tomcat --> 6 <exclusion> 7 <groupId>org.springframework.boot</groupId> 8 <artifactId>spring-boot-starter-tomcat</artifactId> 9 </exclusion> 10 </exclusions> 11 </dependency>
2. The introduction of the dependent servlet
1 <!--添加servlet的依赖 --> 2 <dependency> 3 <groupId>javax.servlet</groupId> 4 <artifactId>javax.servlet-api</artifactId> 5 <scope>provided</scope> 6 </dependency>
3. introduced separately dependent Tomcat
1 <dependency> 2 <groupId>org.springframework.boot</groupId> 3 <artifactId>spring-boot-starter-tomcat</artifactId> 4 <scope>provided</scope> 5 </dependency>
4 is a packaging bag war
<packaging>war</packaging> <dependencies> ... </dependencies>
5. Let Springboot start class inheritance SpringBootServletInitializer, rewrite configure method
1 @SpringBootApplication 2 public class JobSpiderApplication extends SpringBootServletInitializer { 3 4 public static void main(String[] args) { 5 SpringApplication.run(JobSpiderApplication.class, args); 6 } 7 8 @Override 9 protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { 10 return builder.sources(this.getClass()); 11 } 12 13 }
6. Project Right -> Run As-> Maven clean after, Maven install, until the console output "BUILD SUCCESS", to target files in the project folder path find XXX-0.0.1-SNAPSHOT.war package, renamed brief written, copied to the file server Tomcat webapps directory folder.