spring boot 打包至 tomcat 下部署

参考了很多文章,

具体的步骤如下:

1、springboot默认是打jar包,我们需要改成war包


jar更改为war包

2、pom.xml增加依赖

    org.springframework.boot

    spring-boot-starter-tomcat

    provided



3、增加一个初始化的类

import org.springframework.boot.builder.SpringApplicationBuilder;

import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;

public class Initializer extends SpringBootServletInitializer {

    @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application){

        return application.sources(项目application.class);

    }

}



4、可以打包了


先clean,后package


5、部署到tomcat下就可以了

你可能感兴趣的:(spring boot 打包至 tomcat 下部署)