Spring Boot Maven Plugin -- repackage鐩?爣

绠€浠?/span>

銆€銆€Spring Boot Maven Plugin鎻掍欢鎻愪緵spring boot鍦╩aven涓殑鏀寔銆傚厑璁镐綘鎵撳寘鍙繍琛岀殑jar鍖呮垨war鍖呫€?/p>

銆€銆€鎻掍欢鎻愪緵浜嗗嚑涓猰aven鐩爣鍜孲pring Boot 搴旂敤涓€璧峰伐浣溿€傛€荤殑鏈夛細

  • spring-boot:repackage
  • spring-boot:run
  • spring-boot:start and spring-boot:stop 
  • spring-boot:build-info

銆€銆€repackage锛氬垱寤轰竴涓嚜鍔ㄥ彲鎵ц鐨刯ar鎴杦ar鏂囦欢銆傚畠鍙互鏇挎崲甯歌鐨刟rtifact锛屾垨鑰呯敤涓€涓崟鐙殑classifier闄勫睘鍦╩aven鏋勫缓鐨勭敓鍛藉懆鏈熶腑銆?/p>

銆€銆€涓嬮潰鎴戜滑璇︾粏鐪嬩笅repackage杩欎釜鐩爣銆?/p>

涓€銆佺畝鍗曞紩鐢?/span>

 銆€銆€鐢ㄤ簡閲嶆柊鎵撳寘搴旂敤绋嬪簭锛屾垜浠渶瑕佸湪pom.xml鏂囦欢涓姞涓€涓畝鍗曠殑寮曠敤鍒癝pring Boot Maven Plugin鎻掍欢涓紝浠g爜濡備笅锛歳epaceage 鏈€绠€鍗曠殑缁撴瀯

 1 <build>
 2   ...
 3   <plugins>
 4     ...
 5     <plugin>
 6       <groupId>org.springframework.bootgroupId>
 7       <artifactId>spring-boot-maven-pluginartifactId>
 8       <version>1.5.7.RELEASEversion>
 9       <executions>
10         <execution>
11           <goals>
12             <goal>repackagegoal>
13           goals>
14         execution>
15       executions>
16     plugin>
17     ...
18   plugins>
19   ...
20 build>
repaceage 鏈€绠€鍗曠殑缁撴瀯

浜屻€佸墧闄や笉闇€瑕佺殑渚濊禆

銆€銆€杩欎釜渚嬪瓙閲嶆柊鎵撳寘浜嗕竴涓猨ar鍖呮垨war鍖咃紝杩欎釜jar鍖呮垨war鍖呰鏋勫缓浜巑aven鐢熷懡鍛ㄦ湡鐨刾ackage闃舵锛屽寘鎷畾涔夊湪宸ョ▼涓殑浠讳綍渚濊禆锛堝寘鎷瑂cope涓簆rovided锛夈€傚鏋滄湁涓€浜涗緷璧栨ā鍧楅渶瑕佽鎺掗櫎鎺夛紝鍙互浣跨敤涓€涓猠xclude鐨勯€夐」銆?/p>

銆€銆€榛樿鎯呭喌涓嬶紝repackage鍜宺un杩欎袱涓猰aven鐩爣浼氬寘鎷畾涔夊湪宸ョ▼涓殑浠讳綍渚濊禆銆備竴浜涗緷璧栬瑕佹眰浠庡彲鎵цjar鍖呬腑鎺掗櫎銆備笅闈㈡湁涓夌鏂瑰紡鍙互鍦ㄥ寘杩愯鏃舵帓闄や緷璧栨ā鍧椼€?/p>

銆€銆€鏂瑰紡1锛?鎺掗櫎涓€涓叿浣撶殑maven 妯″潡锛岄€氳繃鍞竴鐨刧roupId鍜宎rtifactId缁勫悎鏉ュ疄鐜般€傦紙濡傛灉鏈夊繀瑕侊紝鍙互鍔犲叆classifier鏉ュ敮涓€纭銆傦級

 1 <project>
 2   ...
 3   <build>
 4     ...
 5     <plugins>
 6       ...
 7       <plugin>
 8         <groupId>org.springframework.bootgroupId>
 9         <artifactId>spring-boot-maven-pluginartifactId>
10         <version>1.5.6.RELEASEversion>
11         <configuration>
12           <excludes>
13             <exclude>
14               <groupId>com.foogroupId>
15               <artifactId>barartifactId>
16             exclude>
17           excludes>
18         configuration>
19         ...
20       plugin>
21       ...
22     plugins>
23     ...
24   build>
25   ...
26 project>
鎺掗櫎涓€涓叿浣撶殑maven妯″潡

銆€銆€鏂瑰紡2锛氭帓闄ゅ拰鈥滄寚瀹氱殑artifactId鈥濈浉绗︾殑鎵€鏈塵aven妯″潡銆?/p>

 1 <project>
 2   ...
 3   <build>
 4     ...
 5     <plugins>
 6       ...
 7       <plugin>
 8         <groupId>org.springframework.bootgroupId>
 9         <artifactId>spring-boot-maven-pluginartifactId>
10         <version>1.5.6.RELEASEversion>
11         <configuration>
12           <excludeArtifactIds>my-lib,another-libexcludeArtifactIds>
13         configuration>
14         ...
15       plugin>
16       ...
17     plugins>
18     ...
19   build>
20   ...
21 project>
鎺掗櫎鍜屾寚瀹氱殑artifactId椤圭洰鐨勬墍鏈塵aven妯″潡

銆€銆€鏂瑰紡3锛氭帓闄ゅ睘浜庘€滄寚瀹氱殑groupId鈥濈殑鎵€鏈塵aven妯″潡銆?/p>

 1 <project>
 2   ...
 3   <build>
 4     ...
 5     <plugins>
 6       ...
 7       <plugin>
 8         <groupId>org.springframework.bootgroupId>
 9         <artifactId>spring-boot-maven-pluginartifactId>
10         <version>1.5.6.RELEASEversion>
11         <configuration>
12           <excludeGroupIds>com.fooexcludeGroupIds>
13         configuration>
14         ...
15       plugin>
16       ...
17     plugins>
18     ...
19   build>
20   ...
21 project>
鎺掗櫎灞炰簬鎸囧畾鐨刧roupId鐨勬墍鏈塵aven妯″潡

涓夈€侀噸鍐檓anifest銆€

銆€銆€杩欎釜鎻掍欢杩樺彲浠ラ噸鍐欓」鐩殑manifest 锛堝彲杩愯jar鍖呯殑MANIFEST.MF锛夛紝鐗瑰埆鏄鐞哅ain-Class鍜孲tart-Class鍚姩绫汇€傚鏋滈粯璁ょ殑閰嶇疆涓嶈兘婊¤冻闇€姹傦紝鎴戜滑鍙互鍦ㄨ繖閲屽仛閰嶇疆銆傞€氳繃鎻掍欢鐨?span style="color: #ff0000">layout灞炴€у彲浠ョ‘瀹炲湴鎺у埗Main-Class銆?/p>

 1 <build>
 2   ...
 3   <plugins>
 4     ...
 5     <plugin>
 6       <groupId>org.springframework.bootgroupId>
 7       <artifactId>spring-boot-maven-pluginartifactId>
 8       <version>1.5.7.RELEASEversion>
 9       <configuration>
10         <mainClass>${start-class}mainClass>
11         <layout>ZIPlayout>
12       configuration>
13       <executions>
14         <execution>
15           <goals>
16             <goal>repackagegoal>
17           goals>
18         execution>
19       executions>
20     plugin>
21     ...
22   plugins>
23   ...
24 build>
repackage mainClass

銆€銆€鎵ц鎵撳寘鍛戒护锛歮vn package spring-boot:repackage銆傛敞鎰忥細杩欓噷涓嶈兘鍐欐垚mvn spring-boot:repackage銆傚惁鍒欎細鎶ource must refer to an existing file寮傚父銆?a href="http://blog.csdn.net/taiyangdao/article/details/75519166">

銆€銆€layout灞炴€ч粯璁ゆ牴鎹產rchive type锛坖ar or war锛夎€屽畾銆傛€荤殑鏈?涓被鍨嬶細

  • JAR锛氬父瑙勭殑鍙墽琛宩ar鍖呯殑甯冨眬銆?/li>
  • WAR锛氬彲鎵цwar鍖呯殑甯冨眬銆?/li>
  • ZIP锛堝拰DIR涓€鏍凤級锛氬拰浣跨敤PropertiesLauncher鐨刯ar鍖呭竷灞€涓€鏍枫€?/li>
  • MODULE:鍖呮嫭渚濊禆鍖咃紙鎺掗櫎scope涓簆rovided鐨勪緷璧栧寘锛夊拰椤圭洰璧勬簮
  • NONE:鍖呮嫭鎵€鏈夌殑渚濊禆鍖呭拰椤圭洰璧勬簮銆?/li>

鍥涖€佸埄鐢╟lassifier鍒嗙浠g爜鍖呭拰渚濊禆鍖?/span>

銆€銆€褰撹嚜宸卞啓椤圭洰闇€瑕佸彂甯冨嚭鍘荤粰鍒汉渚濊禆鏃讹紝灏卞彧闇€瑕佽嚜宸卞啓鐨勪唬鐮佹墦鍖咃紝渚濊禆鐨勫寘涓嶈兘鎵撹繘鏉ャ€傚惁鍒欐渶鍚庡埆浜哄湪鐢ㄤ綘鎻愪緵鐨勫寘鏃讹紝灏变細鍑虹幇閲嶅鍖咃紝瀵艰嚧鏈€鍚庢墦鍖呮椂鍖呬細闈炲父宸ㄥぇ銆?/p>

銆€銆€鍦ㄨ繖涓猄pring Boot Maven Plugin杩欎釜鎻掍欢涓嬶紝鎴戜滑鍙渶瑕佹彁渚沜lassifier鍗冲彲瀹炵幇杩欎釜鍔熻兘銆傚叿浣撳涓嬶細

 1 <project>
 2   ...
 3   <build>
 4     ...
 5     <plugins>
 6       ...
 7       <plugin>
 8         <groupId>org.springframework.bootgroupId>
 9         <artifactId>spring-boot-maven-pluginartifactId>
10         <version>1.5.7.RELEASEversion>
11         <executions>
12           <execution>
13             <goals>
14               <goal>repackagegoal>
15             goals>
16             <configuration>
17               <classifier>execclassifier>
18             configuration>
19           execution>
20         executions>
21         ...
22       plugin>
23       ...
24     plugins>
25     ...
26   build>
27   ...
28 project>
repackage classifier

 

銆€銆€鍠滄璇峰叧娉ㄦ垜鐨勫崥瀹?-澹.鐔娿€?/p>

 

你可能感兴趣的:(Spring Boot Maven Plugin -- repackage鐩?爣)