spring boot 鎵搄ar鍖呭垎绂籰ib鍜宺esources
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了spring boot 鎵搄ar鍖呭垎绂籰ib鍜宺esources相关的知识,希望对你有一定的参考价值。
鏍囩锛?a href='http://www.mamicode.com/so/1/%e4%bc%a0%e8%be%93' title='浼犺緭'>浼犺緭
ring includes with output 缂栬緫 绋嬪簭 one 鏂规硶涓轰粈涔堣閰嶇疆銆佷緷璧栨枃浠跺垎绂伙細
1.鍦ㄤ紶缁焜ar鍖呬腑锛屾墍鏈夋枃浠堕兘鎵撳寘鍒颁竴涓猨ar鍖呬腑锛宩ar闈炲父鑷冭偪锛屽湪杩涜鏈嶅姟鏇存柊閮ㄧ讲鏃堕潪甯镐笉渚匡紝鑰屼笖浼犺緭涓嶇ǔ瀹氭椂瀵艰嚧浼犺緭澶辫触銆傚鏋滆繃瀹炶鏂囦欢鍒嗙銆佸湪渚濊禆涓嶆敼鍙樼殑鎯呭喌涓嬶紝浠呬粎涓婁紶鏇存柊鍚庣殑 缂栬瘧鏂囦欢鏄潪甯告柟渚跨殑銆?/p>
- 濡傛灉瑕佷慨鏀逛竴浜涢厤缃枃浠讹細properties銆亁ml锛岄潤鎬佹枃浠剁瓑鍙互鐩存帴鍦ㄦ湇鍔″櫒涓婄紪杈戙€?/li>
閭d箞鎬庝箞瀹炶閰嶇疆銆佷緷璧栨枃浠跺垎绂诲憿锛?/h2>
鎻掍欢浠嬬粛
- maven-jar-plugin 杩欎釜鎻掍欢寮忎笓闂ㄧ敤鏉ユ墦鍖呯敤鐨勶紝鍙互閰嶇疆闇€瑕佹墦鍖呰繘鍘荤殑鏂囦欢锛岀▼搴忕殑鍏ュ彛绫荤瓑銆?/li>
- maven-resources-plugin 杩欎釜鎻掍欢鏄敤鏉ユ嫹璐濊祫婧愭枃浠剁殑銆?/li>
- maven-maven-dependency-plugin 杩欎釜鎻掍欢鏄敤鏉ユ嫹璐濅緷璧栧簱鐨勩€?/li>
- maven-assembly-plugin 鍙互璇村寘鍚簡浠ヤ笂鎻掍欢鐨勫姛鑳斤紝浣嗘槸鍙互鍋氬埌鏇寸簿缁嗙殑鎺у埗銆?/li>
- spring-boot-maven-plugin 杩欎釜涓嶇敤璇达紝springboot 椤圭洰鏈€閲嶈鐨勬彃浠讹紝鏁翠釜椤圭洰鐨勬墦鍖呭鐞嗚繃绋嬭繕鏄渚濋檮浜庡畠銆?/li>
鎵撳寘鎴愬彲鎵цjar锛屼笉浠呬粎灞€闄怱pringBoot椤圭洰锛堜富鍏ュ彛鍑芥暟瀛樺湪锛?/h3>
maven-jar-plugin 鎻掍欢鎵撳寘jar
鍦╬om鏂囦欢涓厤缃?浣嗘槸杩欐牱 渚濊禆鐨刯ar骞朵笉浼氭墦杩涙潵锛堝悗闈細鏈夎В鍐虫柟娉曪級,閫傜敤涓嶉渶瑕佷緷璧栨枃浠剁殑椤圭洰銆?/p>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3</version>
<configuration>
<archive>
<manifest>
<!--鏄惁娣诲姞渚濊禆-->
<addClasspath>true</addClasspath>
<!--璁剧疆鍚姩绫?->
<mainClass>xxx.xxx.Main</mainClass>
</manifest>
</archive>
<!--璁剧疆鐢熸垚jar杈撳嚭浣嶇疆-->
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</plugin>
maven-assembly-plugin 鎻掍欢鎵撳寘jar
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<!--涓嶆坊鍔燗ssemblyId-->
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<!--閰嶇疆鎵撳寘鐨勬椂鍊欎竴骞舵墦鍖呬緷璧杍ar-->
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<!--鍏ュ彛绫?->
<mainClass>xxx.xxx.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!--缁戝畾鐢熷懡鍛ㄦ湡-->
<phase>package</phase>
<goals>
<!--鎵цassembly -->
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
鎵撳寘SpringBoot 椤圭洰
鏂规涓€銆?/h4>
<plugins>
<!--鎵撳寘jar-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<!--MANIFEST.MF 涓?Class-Path 鍔犲叆鍓嶇紑-->
<classpathPrefix>lib/</classpathPrefix>
<!--jar鍖呬笉鍖呭惈鍞竴鐗堟湰鏍囪瘑-->
<useUniqueVersions>false</useUniqueVersions>
<!--鎸囧畾鍏ュ彛绫?->
<mainClass>xxx.xxx.Application</mainClass>
</manifest>
<manifestEntries>
<!--MANIFEST.MF 涓?Class-Path 鍔犲叆璧勬簮鏂囦欢鐩綍-->
<Class-Path>/resources</Class-Path>
</manifestEntries>
</archive>
<outputDirectory>${project.build.directory}/dis</outputDirectory>
</configuration>
</plugin>
<!--鎷疯礉渚濊禆 copy-dependencies-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/dis/lib/
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!--鎷疯礉璧勬簮鏂囦欢 copy-resources-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
- maven-jar-plugin 杩欎釜鎻掍欢寮忎笓闂ㄧ敤鏉ユ墦鍖呯敤鐨勶紝鍙互閰嶇疆闇€瑕佹墦鍖呰繘鍘荤殑鏂囦欢锛岀▼搴忕殑鍏ュ彛绫荤瓑銆?/li>
- maven-resources-plugin 杩欎釜鎻掍欢鏄敤鏉ユ嫹璐濊祫婧愭枃浠剁殑銆?/li>
- maven-maven-dependency-plugin 杩欎釜鎻掍欢鏄敤鏉ユ嫹璐濅緷璧栧簱鐨勩€?/li>
- maven-assembly-plugin 鍙互璇村寘鍚簡浠ヤ笂鎻掍欢鐨勫姛鑳斤紝浣嗘槸鍙互鍋氬埌鏇寸簿缁嗙殑鎺у埗銆?/li>
- spring-boot-maven-plugin 杩欎釜涓嶇敤璇达紝springboot 椤圭洰鏈€閲嶈鐨勬彃浠讹紝鏁翠釜椤圭洰鐨勬墦鍖呭鐞嗚繃绋嬭繕鏄渚濋檮浜庡畠銆?/li>
maven-jar-plugin 鎻掍欢鎵撳寘jar
鍦╬om鏂囦欢涓厤缃?浣嗘槸杩欐牱 渚濊禆鐨刯ar骞朵笉浼氭墦杩涙潵锛堝悗闈細鏈夎В鍐虫柟娉曪級,閫傜敤涓嶉渶瑕佷緷璧栨枃浠剁殑椤圭洰銆?/p>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.3</version>
<configuration>
<archive>
<manifest>
<!--鏄惁娣诲姞渚濊禆-->
<addClasspath>true</addClasspath>
<!--璁剧疆鍚姩绫?->
<mainClass>xxx.xxx.Main</mainClass>
</manifest>
</archive>
<!--璁剧疆鐢熸垚jar杈撳嚭浣嶇疆-->
<outputDirectory>${project.build.directory}</outputDirectory>
</configuration>
</plugin>
maven-assembly-plugin 鎻掍欢鎵撳寘jar
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<!--涓嶆坊鍔燗ssemblyId-->
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<!--閰嶇疆鎵撳寘鐨勬椂鍊欎竴骞舵墦鍖呬緷璧杍ar-->
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
<archive>
<manifest>
<!--鍏ュ彛绫?->
<mainClass>xxx.xxx.Main</mainClass>
</manifest>
</archive>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<!--缁戝畾鐢熷懡鍛ㄦ湡-->
<phase>package</phase>
<goals>
<!--鎵цassembly -->
<goal>assembly</goal>
</goals>
</execution>
</executions>
</plugin>
鎵撳寘SpringBoot 椤圭洰
鏂规涓€銆?/h4>
<plugins>
<!--鎵撳寘jar-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<!--MANIFEST.MF 涓?Class-Path 鍔犲叆鍓嶇紑-->
<classpathPrefix>lib/</classpathPrefix>
<!--jar鍖呬笉鍖呭惈鍞竴鐗堟湰鏍囪瘑-->
<useUniqueVersions>false</useUniqueVersions>
<!--鎸囧畾鍏ュ彛绫?->
<mainClass>xxx.xxx.Application</mainClass>
</manifest>
<manifestEntries>
<!--MANIFEST.MF 涓?Class-Path 鍔犲叆璧勬簮鏂囦欢鐩綍-->
<Class-Path>/resources</Class-Path>
</manifestEntries>
</archive>
<outputDirectory>${project.build.directory}/dis</outputDirectory>
</configuration>
</plugin>
<!--鎷疯礉渚濊禆 copy-dependencies-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/dis/lib/
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!--鎷疯礉璧勬簮鏂囦欢 copy-resources-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>
<plugins>
<!--鎵撳寘jar-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<!--MANIFEST.MF 涓?Class-Path 鍔犲叆鍓嶇紑-->
<classpathPrefix>lib/</classpathPrefix>
<!--jar鍖呬笉鍖呭惈鍞竴鐗堟湰鏍囪瘑-->
<useUniqueVersions>false</useUniqueVersions>
<!--鎸囧畾鍏ュ彛绫?->
<mainClass>xxx.xxx.Application</mainClass>
</manifest>
<manifestEntries>
<!--MANIFEST.MF 涓?Class-Path 鍔犲叆璧勬簮鏂囦欢鐩綍-->
<Class-Path>/resources</Class-Path>
</manifestEntries>
</archive>
<outputDirectory>${project.build.directory}/dis</outputDirectory>
</configuration>
</plugin>
<!--鎷疯礉渚濊禆 copy-dependencies-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/dis/lib/
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
<!--鎷疯礉璧勬簮鏂囦欢 copy-resources-->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-resources</id>
<phase>package</phase>