1. 程式人生 > >spring boot 打成war包釋出

spring boot 打成war包釋出

啟動類 -- xxxApplication.java

繼承 

extends SpringBootServletInitializer

重寫

// 打war包需要
@Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
    builder.sources(xxxApplication.class);
    return super.configure(builder);
}

pom.xml

將packaging內的jar更改為war

<!--打war包需要-->
<packaging>war</packaging>

新增

<!--打war包需要-->
<dependency>
    <groupId>javax.servlet</groupId>
    <artifactId>javax.servlet-api</artifactId>
    <version>3.1.0</version>
    <scope>provided</scope>
</dependency>

---------------------------------------------------------------------------------------------

開發時將上述內容註釋,packaging內的war更改為jar

雙擊install,打成war包的在專案的target資料夾下,取出改名為ROOT.war扔到小貓裡