spring boot 打包至 tomcat 下部署

参考了很多文章,

具体的步骤如下:

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


jar更改为war包

2、pom.xml增加依赖

<dependency>

    <groupId>org.springframework.boot</groupId>

    <artifactId>spring-boot-starter-tomcat</artifactId>

    <scope>provided</scope>

</dependency>


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下就可以了

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。