SpringBoot慕课学习-war包-打包war

  1. pom.xml中将packaging改为war,并update项目(eclipse项目报红)
  2. 引入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项目

posted @ 2018-09-06 21:26  BigOrang  阅读(137)  评论(0编辑  收藏  举报