因springboot默認的打包方式爲jar,須要經過java -jar test.jar來完成部署,而通常服務器是要採用tomcat或者weblogic等web容器進行部署的,須要將jar改爲打war包java
其實改爲war包只須要更改幾個地方的配置就好了,也比較簡單。web
通常多模塊開發的話,就web下面的pom.xmlspring
<packaging>war</packaging>
<build> <plugins> <plugin> <artifactId>maven-war-plugin</artifactId> <version>3.0.0</version> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>8</source> <target>8</target> </configuration> </plugin> </plugins> </build>
@SpringBootApplication public class Application extends SpringBootServletInitializer { @Override protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Application.class); } public static void main(String[] args) { SpringApplication.run(Application.class, args); } }