最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Spring Boot打war包的實(shí)例教程

 更新時(shí)間:2018年02月07日 16:03:50   作者:馬軍偉  
本篇文章主要介紹了Spring Boot打war包的實(shí)例教程,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧

Spring Boot除了可以打可執(zhí)行jar包外,也支持傳統(tǒng)的war包。本文介紹如何使用Spring Boot構(gòu)建傳統(tǒng)war包。

Spring Boot打war包步驟如下:

1、在pom.xml里定義打包類型

<packaging>war</packaging>

2、添加Spring Boot啟動(dòng)器(也可通過parent)

  <dependencyManagement>
 <dependencies>
  <dependency>
  <!-- Import dependency management from Spring Boot -->
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-dependencies</artifactId>
  <version>1.5.6.RELEASE</version>
  <type>pom</type>
  <scope>import</scope>
  </dependency>
 </dependencies>
 </dependencyManagement>

3、添加spring-boot-starter-web依賴

    <dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-web</artifactId>
  <exclusions>
  <exclusion>
   <groupId>org.springframework.boot</groupId>
   <artifactId>spring-boot-starter-tomcat</artifactId>
  </exclusion>
  </exclusions>
 </dependency>

4、添加打包插件

  <build>
 <plugins>
  <plugin>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-maven-plugin</artifactId>
  </plugin>
 </plugins>
 </build>

5、主類繼承SpringBootServletInitializer

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

6、執(zhí)行mvn clean package打包

$mvn clean package

7、將打好的war包拷貝到容器(如tomcat)運(yùn)行即可。

這里需要簡(jiǎn)單說明下:

主應(yīng)用可以重寫SpringBootServletInitializer里面有configure方法,自定義配置Spring Boot。

  /**
 * Configure the application. Normally all you would need to do is to add sources
 * (e.g. config classes) because other settings have sensible defaults. You might
 * choose (for instance) to add default command line arguments, or set an active
 * Spring profile.
 * @param builder a builder for the application context
 * @return the application builder
 * @see SpringApplicationBuilder
 */
 protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
 return builder;
 }

實(shí)例源碼下載

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論

潼南县| 锡林郭勒盟| 河津市| 长顺县| 吕梁市| 分宜县| 乌鲁木齐县| 思南县| 米脂县| 咸阳市| 苗栗县| 大石桥市| 平江县| 天峨县| 延安市| 惠水县| 腾冲县| 泾阳县| 大渡口区| 溆浦县| 肥东县| 饶阳县| 新晃| 桃园市| 岳阳市| 玉环县| 黄浦区| 喀什市| 五华县| 宿州市| 葫芦岛市| 古浪县| 贵港市| 长泰县| 柏乡县| 雅安市| 论坛| 灌阳县| 隆化县| 修武县| 准格尔旗|