springboot war部署

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部署

上一篇:JSTL标签报错-http://java.sun.com/jsp/jstl/core


下一篇:python 3rd 函数(1)