maven assembly plugin,maven dependency plugin的使用

maven assembly plugin: 将第三方jar包和应用集成打成一个jar包,打包时使用mvn clean, mvn assembly:assembly, jar文件会比较冗余盘大

maven dependency plugin: 将第三方jar包打包到一个文件夹中,打包时使用mvn clean,mvn package,服务器上上传一次lib包,后面的应用程序jar包文件很小

暂时理解Pom.xml文件中配置一个就可以了 如下:

点击(此处)折叠或打开

  1. <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  2.     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  3.     <modelVersion>4.0.0</modelVersion>
  4.     <groupId>com.sany</groupId>
  5.     <artifactId>ECCDataElasticSearch</artifactId>
  6.     <version>0.0.1-SNAPSHOT</version>
  7.     <build>
  8.         <finalName>ECCDataElasticSearch</finalName> <!-- 指定输出到target目录的jar包名称 -->
  9.         <plugins>
  10.         
  11.         <!-------------------- maven assembly plugin ------------------------>
  12. <!--             <plugin> -->
  13. <!--                 <artifactId>maven-assembly-plugin</artifactId> -->
  14. <!--                 <version>2.6</version> -->
  15. <!--                 <configuration> -->
  16. <!--                     <descriptorRefs> -->
  17. <!--                         <descriptorRef>jar-with-dependencies</descriptorRef> -->
  18. <!--                     </descriptorRefs> -->
  19. <!--                     <archive> -->
  20. <!--                         <manifest> -->
  21. <!--                             <mainClass>com.sany.ecc.WkTimeCal</mainClass> -->
  22. <!--                         </manifest> -->
  23. <!--                     </archive> -->
  24. <!--                 </configuration> -->
  25. <!--             </plugin> -->

  26.         
  27.         <!-- maven-dependency-plugin -------------------------------------------------------->    
  28.             <plugin>
  29.             <groupId>org.apache.maven.plugins</groupId>
  30.             <artifactId>maven-dependency-plugin</artifactId>
  31.             <executions>
  32.                 <execution>
  33.                     <id>copy-dependencies</id>
  34.                     <phase>prepare-package</phase>
  35.                     <goals>
  36.                         <goal>copy-dependencies</goal>
  37.                     </goals>
  38.                     <configuration>
  39.                         <outputDirectory>${project.build.directory}/lib</outputDirectory>
  40.                         <overWriteReleases>false</overWriteReleases>
  41.                         <overWriteSnapshots>false</overWriteSnapshots>
  42.                         <overWriteIfNewer>true</overWriteIfNewer>
  43.                     </configuration>
  44.                 </execution>
  45.             </executions>
  46.         </plugin>
  47.         <plugin>
  48.             <groupId>org.apache.maven.plugins</groupId>
  49.             <artifactId>maven-jar-plugin</artifactId>
  50.             <configuration>
  51.                 <archive>
  52.                     <manifest>
  53.                         <addClasspath>true</addClasspath>
  54.                         <classpathPrefix>lib/</classpathPrefix>
  55.                         <mainClass>com.sany.ecc.WkTimeCal</mainClass>
  56.                     </manifest>
  57.                 </archive>
  58.             </configuration>
  59.         </plugin>
  60.         </plugins>
  61.     </build>

  62.     <dependencies>
  63.         <!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
  64.         <dependency>
  65.             <groupId>org.elasticsearch</groupId>
  66.             <artifactId>elasticsearch</artifactId>
  67.             <version>2.3.3</version>
  68.         </dependency>

  69.         <!-- https://mvnrepository.com/artifact/log4j/log4j -->
  70.         <dependency>
  71.             <groupId>log4j</groupId>
  72.             <artifactId>log4j</artifactId>
  73.             <version>1.2.17</version>
  74.         </dependency>

  75.         <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
  76.         <dependency>
  77.             <groupId>mysql</groupId>
  78.             <artifactId>mysql-connector-java</artifactId>
  79.             <version>5.1.6</version>
  80.         </dependency>

  81.         <dependency>
  82.             <groupId>org.apache.kafka</groupId>
  83.             <artifactId>kafka_2.10</artifactId>
  84.             <version>0.8.2.1</version>
  85.         </dependency>
  86.     </dependencies>
  87. </project>


来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31347383/viewspace-2122027/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/31347383/viewspace-2122027/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值