- pom.xml中将packaging改为war,并update项目(eclipse项目报红)
- 引入tomcat依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-tomcat</artifactId> </dependency>
3. 修改启动类 为继承 SpringBootServletInitializer
4. 重写启动类的 configure方法,方法中return builder.sources(XXX.class); //XXX为自己的启动类
@SpringBootApplication public class StartDemoApplication extends SpringBootServletInitializer{ @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { // TODO Auto-generated method stub return builder.sources(StartDemoApplication.class); //启动类 } public static void main(String[] args) { SpringApplication.run(StartDemoApplication.class, args); } }
5. clean 项目
6. install项目