IDEA maven 打可執行jar包 包括依賴jar檔案和所有配置檔案資原始檔
阿新 • • 發佈:2019-02-19
目標 1. 將依賴第三方jar包都打進去
2. 將工程java 目錄下所有資料夾和配置檔案,包括資原始檔都打入jar包,根據目錄來
3. 打出jar檔案可直接執行
方法:採用 maven-assembly-plugin
環境:IDEA 14.1.5 JDK 1.8
其中**/*寫法,是為了保證各級子目錄下的資原始檔被打包,svn相關檔案排除。
pom.xml 寫法
<build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*</include> </includes> <excludes> <exclude>**/.svn/*</exclude> </excludes> <filtering>false</filtering> </resource> </resources></span> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.3.2</version> <configuration> <source>1.8</source> <target>1.8</target> <encoding>UTF-8</encoding> <compilerArguments> <verbose /> <bootclasspath>${java.home}\lib\rt.jar;${java.home}\lib\jce.jar</bootclasspath> </compilerArguments> </configuration> </plugin> <plugin> <artifactId>maven-assembly-plugin</artifactId> <configuration> <appendAssemblyId>false</appendAssemblyId> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> <archive> <manifest> <mainClass>com.teraee.xx.Xxx</mainClass> </manifest> </archive> </configuration> <executions> <execution> <id>make-assembly</id> <phase>package</phase> <goals> <goal>assembly</goal> </goals> </execution> </executions> </plugin></span> </plugins> </build>