Maven项目学习(二)配置打包和主函数

举报
鱼酱 发表于 2022/01/06 22:27:17 2022/01/06
【摘要】 https://github.com/groovy/groovy-eclipse/wiki  groovy插件 打包文件方法一 <plugins> <plugin> <groupId>org.apache.maven.plugins</group...

https://github.com/groovy/groovy-eclipse/wiki  groovy插件




打包文件方法一


  
  1. <plugins>
  2. <plugin>
  3. <groupId>org.apache.maven.plugins</groupId>
  4. <artifactId>maven-shade-plugin</artifactId>
  5. <executions>
  6. <execution>
  7. <phase>package</phase>
  8. <goals>
  9. <goal>shade</goal>
  10. </goals>
  11. <configuration>
  12. <transformers>
  13. <transformer
  14. implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
  15. <mainClass>test.testB.App</mainClass>
  16. </transformer>
  17. </transformers>
  18. </configuration>
  19. </execution>
  20. </executions>
  21. </plugin>
  22. </plugins>



  
  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>test</groupId>
  5. <artifactId>testB</artifactId>
  6. <version>0.0.1-SNAPSHOT</version>
  7. <name>testB</name>
  8. <url>http://maven.apache.org</url>
  9. <properties>
  10. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  11. </properties>
  12. <dependencies>
  13. <dependency>
  14. <groupId>junit</groupId>
  15. <artifactId>junit</artifactId>
  16. <version>3.8.1</version>
  17. <scope>test</scope>
  18. </dependency>
  19. <dependency>
  20. <groupId>test</groupId>
  21. <artifactId>testA</artifactId>
  22. <version>0.0.1-SNAPSHOT</version>
  23. </dependency>
  24. <dependency>
  25. <groupId>log4j</groupId>
  26. <artifactId>log4j</artifactId>
  27. <version>1.2.12</version>
  28. </dependency>
  29. </dependencies>
  30. <build>
  31. <plugins>
  32. <plugin>
  33. <groupId>org.apache.maven.plugins</groupId>
  34. <artifactId>maven-dependency-plugin</artifactId>
  35. <executions>
  36. <execution>
  37. <id>copy</id>
  38. <phase>package</phase>
  39. <goals>
  40. <goal>copy-dependencies</goal>
  41. </goals>
  42. <configuration>
  43. <!-- 依赖库输出到lib文件夹-->
  44. <outputDirectory>${project.build.directory}/lib</outputDirectory>
  45. </configuration>
  46. </execution>
  47. </executions>
  48. </plugin>
  49. <plugin>
  50. <groupId>org.apache.maven.plugins</groupId>
  51. <artifactId>maven-jar-plugin</artifactId>
  52. <version>2.4</version>
  53. <configuration>
  54. <archive>
  55. <manifest>
  56. <addClasspath>true</addClasspath>
  57. <classpathPrefix>lib/</classpathPrefix>
  58. <!-- 主函数 -->
  59. <mainClass>test.testB.App</mainClass>
  60. <addDefaultImplementationEntries>true</addDefaultImplementationEntries>
  61. </manifest>
  62. <manifestEntries>
  63. <Class-Path>.</Class-Path>
  64. </manifestEntries>
  65. </archive>
  66. <excludes>
  67. <exclude>*.properties</exclude>
  68. <exclude>conf/**</exclude>
  69. <exclude>*.xml</exclude>
  70. <exclude>*.dtd</exclude>
  71. <exclude>*.txt</exclude>
  72. <exclude>*.json</exclude>
  73. </excludes>
  74. </configuration>
  75. <executions>
  76. <execution>
  77. <phase>package</phase>
  78. <goals>
  79. <goal>jar</goal>
  80. </goals>
  81. </execution>
  82. </executions>
  83. </plugin>
  84. </plugins>
  85. </build>
  86. </project>





文章来源: yujiang.blog.csdn.net,作者:鱼酱2333,版权归原作者所有,如需转载,请联系作者。

原文链接:yujiang.blog.csdn.net/article/details/78324033

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。