maven assembly plugin: 将第三方jar包和应用集成打成一个jar包,打包时使用mvn clean, mvn assembly:assembly, jar文件会比较冗余盘大
maven dependency plugin: 将第三方jar包打包到一个文件夹中,打包时使用mvn clean,mvn package,服务器上上传一次lib包,后面的应用程序jar包文件很小
暂时理解Pom.xml文件中配置一个就可以了 如下:
maven dependency plugin: 将第三方jar包打包到一个文件夹中,打包时使用mvn clean,mvn package,服务器上上传一次lib包,后面的应用程序jar包文件很小
暂时理解Pom.xml文件中配置一个就可以了 如下:
点击(此处)折叠或打开
- <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>com.sany</groupId>
- <artifactId>ECCDataElasticSearch</artifactId>
- <version>0.0.1-SNAPSHOT</version>
- <build>
- <finalName>ECCDataElasticSearch</finalName> <!-- 指定输出到target目录的jar包名称 -->
- <plugins>
-
- <!-------------------- maven assembly plugin ------------------------>
- <!-- <plugin> -->
- <!-- <artifactId>maven-assembly-plugin</artifactId> -->
- <!-- <version>2.6</version> -->
- <!-- <configuration> -->
- <!-- <descriptorRefs> -->
- <!-- <descriptorRef>jar-with-dependencies</descriptorRef> -->
- <!-- </descriptorRefs> -->
- <!-- <archive> -->
- <!-- <manifest> -->
- <!-- <mainClass>com.sany.ecc.WkTimeCal</mainClass> -->
- <!-- </manifest> -->
- <!-- </archive> -->
- <!-- </configuration> -->
- <!-- </plugin> -->
-
-
- <!-- maven-dependency-plugin -------------------------------------------------------->
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <executions>
- <execution>
- <id>copy-dependencies</id>
- <phase>prepare-package</phase>
- <goals>
- <goal>copy-dependencies</goal>
- </goals>
- <configuration>
- <outputDirectory>${project.build.directory}/lib</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>false</overWriteSnapshots>
- <overWriteIfNewer>true</overWriteIfNewer>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-jar-plugin</artifactId>
- <configuration>
- <archive>
- <manifest>
- <addClasspath>true</addClasspath>
- <classpathPrefix>lib/</classpathPrefix>
- <mainClass>com.sany.ecc.WkTimeCal</mainClass>
- </manifest>
- </archive>
- </configuration>
- </plugin>
- </plugins>
- </build>
-
- <dependencies>
- <!-- https://mvnrepository.com/artifact/org.elasticsearch/elasticsearch -->
- <dependency>
- <groupId>org.elasticsearch</groupId>
- <artifactId>elasticsearch</artifactId>
- <version>2.3.3</version>
- </dependency>
-
- <!-- https://mvnrepository.com/artifact/log4j/log4j -->
- <dependency>
- <groupId>log4j</groupId>
- <artifactId>log4j</artifactId>
- <version>1.2.17</version>
- </dependency>
-
- <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
- <dependency>
- <groupId>mysql</groupId>
- <artifactId>mysql-connector-java</artifactId>
- <version>5.1.6</version>
- </dependency>
-
- <dependency>
- <groupId>org.apache.kafka</groupId>
- <artifactId>kafka_2.10</artifactId>
- <version>0.8.2.1</version>
- </dependency>
- </dependencies>
- </project>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/31347383/viewspace-2122027/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/31347383/viewspace-2122027/