SpringBoot 打war包

SpringBoot 打war包

pom.xml

设置打包格式

<packaging>war</packaging>

添加依赖

<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
</dependency>

设置打包文件名

<build>
    <finalName>apibrowselog</finalName>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

编译、测试、运行是 加入tomcat依赖

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-tomcat</artifactId>
    <scope>provided</scope>
</dependency>

修改启动类

@SpringBootApplication
public class BrowseLogApplication extends SpringBootServletInitializer {

    public static void main(String[] args) {
        SpringApplication.run(BrowseLogApplication.class, args);
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application){
        return application.sources(BrowseLogApplication.class);
    }
}
posted @ 2020-04-18 11:48  彦桢  阅读(230)  评论(0编辑  收藏  举报