maven可執行jar包
阿新 • • 發佈:2018-03-27
maven
2 插件2:
參見: http://maven.apache.org/plugins/maven-assembly-plugin/usage.html
參見: http://blog.csdn.net/WANGYAN9110/article/details/38646677/
[待續。。。]
-
插件1:
<build> <plugins> <!-- 1. 生成MANIFEST.MF文件 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-jar-plugin</artifactId> <version>2.6</version> <configuration> <archive> <manifest> <addClasspath>true</addClasspath> <classpathPrefix>lib/</classpathPrefix> <mainClass>com.ns.runable.RunnableTest</mainClass> </manifest> </archive> </configuration> </plugin> <!-- 將依賴包拷貝到<outputDirectory>${project.build.directory}/lib</outputDirectory>指定的位置,即lib目錄下 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <version>2.10</version> <executions> <execution> <id>copy-dependencies</id> <phase>package</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> </configuration> </execution> </executions> </plugin> </plugins> </build>
缺點:生成的jar包太多不便於管理,看下面這個插件:只生成一個包含依賴資源和依賴包的jar;
<build> <finalName>kafka_go</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-assembly-plugin</artifactId> <version>3.0.0</version> <configuration> <archive> <manifest> <mainClass>chap2.ProducerDemo</mainClass> </manifest> </archive> <descriptorRefs> <descriptorRef>jar-with-dependencies</descriptorRef> </descriptorRefs> </configuration> <executions> <execution> <id>make-assembly</id> <!-- this is used for inheritance merges --> <phase>package</phase> <!-- bind to the packaging phase --> <goals> <goal>single</goal> </goals> </execution> </executions> </plugin> </plugins> </build>
[待續。。。]
maven可執行jar包