1. 启动类继承SpringBootServletInitializer,重写configure方法
1 @SpringBootApplication 2 public class MyApplication extends SpringBootServletInitializer { 3 4 public static void main(String[] args) { 5 SpringApplication.run(MyApplication.class, args); 6 } 7 8 @Override 9 protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { 10 return builder.sources(MyApplication.class); 11 } 12 }
2. pom.xml:
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins> </build>
3.