[关闭]
@tsing1226 2016-09-29T16:58:07.000000Z 字数 1194 阅读 840

java maven

java项目打包maven pom.xml配置


java项目打包时包含第三方jar包

pom.xml

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <artifactId>maven-assembly-plugin</artifactId>
  5. <configuration>
  6. <descriptorRefs>
  7. <descriptorRef>jar-with-dependencies</descriptorRef>
  8. </descriptorRefs>
  9. <archive>
  10. <manifest>
  11. <mainClass>TaskMain</mainClass>
  12. </manifest>
  13. </archive>
  14. </configuration>
  15. <executions>
  16. <execution>
  17. <id>make-assembly</id>
  18. <phase>package</phase>
  19. <goals>
  20. <goal>single</goal>
  21. </goals>
  22. </execution>
  23. </executions>
  24. </plugin>
  25. </plugins>
  26. </build>

java项目打包不包含第三方java包

pom.xml

  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.apache.maven.plugins</groupId>
  5. <artifactId>maven-jar-plugin</artifactId>
  6. <version>2.4</version>
  7. <configuration>
  8. <archive>
  9. <manifest>
  10. <addClasspath>true</addClasspath>
  11. <classpathPrefix>lib/</classpathPrefix>
  12. <mainClass>TaskMain</mainClass>
  13. </manifest>
  14. </archive>
  15. </configuration>
  16. </plugin>
  17. <plugin>
  18. <groupId>org.apache.maven.plugins</groupId>
  19. <artifactId>maven-dependency-plugin</artifactId>
  20. <executions>
  21. <execution>
  22. <id>copy</id>
  23. <phase>package</phase>
  24. <goals>
  25. <goal>copy-dependencies</goal>
  26. </goals>
  27. <configuration>
  28. <outputDirectory>${project.build.directory}/lib</outputDirectory>
  29. </configuration>
  30. </execution>
  31. </executions>
  32. </plugin>
  33. </plugins>
  34. </build>
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注