美文网首页
springboot怎么打成war包

springboot怎么打成war包

作者: touch_The_Sky | 来源:发表于2018-11-07 11:44 被阅读0次

1.添加spring-boot-starter-tomcat的依赖,scope provided
2.添加maven-war-plugin插件

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

    <build>
        <finalName>${project.artifactId}</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <configuration>
                    <failOnMissingWebXml>false</failOnMissingWebXml>
                </configuration>
            </plugin>
        </plugins>
    </build>
  1. 修改打包方式为war : <packaging>war</packaging>
    3.spingboot Application类继承SpringBootServletInitializer 并覆盖configure方法
@SpringBootApplication
public class Demo extends SpringBootServletInitializer{
    public static void main(String[] args) {
        SpringApplication.run(Demo.class); 
    }

    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(Demo.class);
    }
}


相关文章

网友评论

      本文标题:springboot怎么打成war包

      本文链接:https://www.haomeiwen.com/subject/jbokzftx.html