1. 程式人生 > >intelij 2018生成war部署到tomcat

intelij 2018生成war部署到tomcat

(1)在pom.xml中修改war

(2)而後新增tomcat依賴

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

(3)還可以在build中通過新增<finalName>設定專案打包好的名字

<finalName>chennbgetdata</finalName>

(4)註釋修改主函式

/*@SpringBootApplication
public class GetdataApplication {
   public static void main(String[] args) {
      SpringApplication.run(GetdataApplication.class, args);
   }
}
*/
@SpringBootApplication
public class GetdataApplication extends SpringBootServletInitializer {

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

   public static void main(String[] args) {
      SpringApplication.run(GetdataApplication.class, args);
   }
}

(5)通過maven打包,依次點選clean,package和install

(6)生成的包放在\apache-tomcat-9.0.12\webapps目錄下,啟動tomcat就可以了