首页 > 编程语言 > 详细

springboot war部署

时间:2021-08-29 23:12:49      阅读:33      评论:0      收藏:0      [点我收藏+]

springboot war部署

将打包方式设置为war(pom.xml文件)

    <packaging>war</packaging>

移除tomcat

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
            <!-- 移除嵌入式tomcat插件 -->

            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-tomcat</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
        <!--HttpServletRequest所需-->
        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>javax.servlet-api</artifactId>
            <scope>provided</scope>
        </dependency>

改写启动类

继承SpringBootServletInitializer

@SpringBootApplication
//public class BlogsApplication {
public class BlogsApplication extends SpringBootServletInitializer {

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder application) {
        return application.sources(BlogsApplication.class);
    }

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

}

利用maven打包

springboot war部署

原文:https://www.cnblogs.com/xiaozhizxj/p/15202302.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!