Maven 打包配置

心已赠人 2022-03-20 10:26 413阅读 0赞

1.pom.xml文件的build节点

  1. <build>
  2. <!-- 配置资源文件-->
  3. <resources>
  4. <resource>
  5. <directory>src/main/resources</directory>
  6. <filtering>true</filtering>
  7. </resource>
  8. </resources>
  9. <plugins>
  10. <!-- 配置资源文件插件-->
  11. <plugin>
  12. <artifactId>maven-resources-plugin</artifactId>
  13. <version>2.5</version>
  14. <configuration>
  15. <encoding>UTF-8</encoding>
  16. </configuration>
  17. </plugin>
  18. <!-- 配置编译插件-->
  19. <plugin>
  20. <groupId>org.apache.maven.plugins</groupId>
  21. <artifactId>maven-compiler-plugin</artifactId>
  22. <configuration>
  23. <source>1.8</source>
  24. <target>1.8</target>
  25. </configuration>
  26. <version>3.3</version>
  27. </plugin>
  28. <plugin>
  29. <!--创建打包方式及传输方式-->
  30. <artifactId>maven-assembly-plugin</artifactId>
  31. <version>2.2.1</version>
  32. <dependencies>
  33. <dependency>
  34. <groupId>org.apache.maven</groupId>
  35. <artifactId>maven-core</artifactId>
  36. <version>2.2.1</version>
  37. </dependency>
  38. </dependencies>
  39. <configuration>
  40. <appendAssemblyId>false</appendAssemblyId>
  41. <descriptors>
  42. <descriptor>src/main/assemble/package.xml</descriptor>
  43. </descriptors>
  44. </configuration>
  45. <executions>
  46. <execution>
  47. <id>make-assembly</id>
  48. <phase>package</phase>
  49. <goals>
  50. <goal>single</goal>
  51. </goals>
  52. </execution>
  53. </executions>
  54. </plugin>
  55. </plugins>
  56. </build>

2.package.xm

  1. <assembly>
  2. <id>package</id>
  3. <formats>
  4. <format>dir</format>
  5. <format>zip</format>
  6. </formats>
  7. <includeBaseDirectory>true</includeBaseDirectory>
  8. <fileSets>
  9. <fileSet>
  10. <directory>src/main/bin</directory>
  11. <outputDirectory>bin</outputDirectory>
  12. </fileSet>
  13. <fileSet>
  14. <directory>src/main/resources</directory>
  15. <outputDirectory>/conf</outputDirectory>
  16. <filtered>true</filtered>
  17. <excludes>
  18. <exclude>**/*.xls</exclude>
  19. <exclude>**/*.vm</exclude>
  20. </excludes>
  21. </fileSet>
  22. <fileSet>
  23. <directory>src/main/resources</directory>
  24. <outputDirectory>/conf</outputDirectory>
  25. <filtered>false</filtered>
  26. <includes>
  27. <include>**/*.xls</include>
  28. <include>**/*.vm</include>
  29. </includes>
  30. </fileSet>
  31. <fileSet>
  32. <directory>lib</directory>
  33. <outputDirectory>lib</outputDirectory>
  34. </fileSet>
  35. </fileSets>
  36. <dependencySets>
  37. <dependencySet>
  38. <outputDirectory>lib</outputDirectory>
  39. <scope>runtime</scope>
  40. </dependencySet>
  41. </dependencySets>
  42. </assembly>

参考地址
https://www.cnblogs.com/Andrew520/p/8857603.html
https://www.cnblogs.com/brant/p/maven.html
https://www.cnblogs.com/pixy/p/4798089.html

发表评论

表情:
评论列表 (有 0 条评论,413人围观)

还没有评论,来说两句吧...

相关阅读