1. 程式人生 > >將專案打包成war(基於maven springboot)

將專案打包成war(基於maven springboot)

首先:將jar變成war

pom.xml中

<packaging>war</packaging>
其次:在pom.xml中加下列依賴:
<dependency>
 <groupId>org.springframework.boot</groupId>
       <artifactId>spring-boot-starter-tomcat</artifactId>
       <scope>provided</scope>//注意:執行專案的時候需要將這句話註釋掉  不然會報錯
 </dependency>
最後:在啟動類中:
public class ServletInitializer extends SpringBootServletInitializer {  

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

}