修改启动类
改成继承org.springframework.boot.web.servlet.support.SpringBootServletInitializer, 例如:
1 2 3 4 5 6 7 8 9 10 11 12 13
| package cn.devmgr.tutorial;
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
@SpringBootApplication public class Application extends SpringBootServletInitializer{
public static void main(String[] args) { SpringApplication.run(Application.class, args); } }
|
修改pom文件
改packaging方式为war
1
| <packaging>war</packaging>
|
改依赖
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
| <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-rest</artifactId> <exclusions> <exclusion> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </exclusion> </exclusions> </dependency>
<dependency> <groupId>javax.servlet</groupId> <artifactId>javax.servlet-api</artifactId> <scope>provided</scope> </dependency>
|
注意事项
spring boot 2.0项目需要在tomcat 8.5以上版本环境下运行