当前位置:   article > 正文

maven打包_copy-dependencies

copy-dependencies
  1. <build>
  2. <plugins>
  3. <plugin>
  4. <groupId>org.apache.maven.plugins</groupId>
  5. <artifactId>maven-jar-plugin</artifactId>
  6. <version>2.6</version>
  7. <configuration>
  8. <archive>
  9. <manifest>
  10. <addClasspath>true</addClasspath>
  11. <classpathPrefix>lib/</classpathPrefix>
  12. <mainClass>com.broadtech.bdvmonitor.BdvMonitorWebappApplication</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. <version>2.10</version>
  21. <executions>
  22. <execution>
  23. <id>copy-dependencies</id>
  24. <phase>package</phase>
  25. <goals>
  26. <goal>copy-dependencies</goal>
  27. </goals>
  28. <configuration>
  29. <outputDirectory>${project.build.directory}/lib</outputDirectory>
  30. </configuration>
  31. </execution>
  32. </executions>
  33. </plugin>
  34. </plugins>
  35. </build>

如果提示错误,请添加

  1. <dependency>
  2. <groupId>jdk.tools</groupId>
  3. <artifactId>jdk.tools</artifactId>
  4. <version>1.6</version>
  5. <scope>system</scope>
  6. <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
  7. </dependency>

 

 

 

完整的pom.xml

  1. <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">
  2. <modelVersion>4.0.0</modelVersion>
  3. <groupId>com.broadtech</groupId>
  4. <artifactId>bdvmonitor-webapp</artifactId>
  5. <version>0.0.1-SNAPSHOT</version>
  6. <parent>
  7. <groupId>org.springframework.boot</groupId>
  8. <artifactId>spring-boot-starter-parent</artifactId>
  9. <version>1.5.9.RELEASE</version>
  10. <relativePath/> <!-- lookup parent from repository -->
  11. </parent>
  12. <properties>
  13. <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  14. <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
  15. <java.version>1.8</java.version>
  16. </properties>
  17. <dependencies>
  18. <dependency>
  19. <groupId>jdk.tools</groupId>
  20. <artifactId>jdk.tools</artifactId>
  21. <version>1.6</version>
  22. <scope>system</scope>
  23. <systemPath>${JAVA_HOME}/lib/tools.jar</systemPath>
  24. </dependency>
  25. <dependency>
  26. <groupId>org.springframework.boot</groupId>
  27. <artifactId>spring-boot-starter</artifactId>
  28. </dependency>
  29. <dependency>
  30. <groupId>org.springframework.cloud</groupId>
  31. <artifactId>spring-cloud-starter-eureka</artifactId>
  32. </dependency>
  33. <dependency>
  34. <groupId>org.springframework.boot</groupId>
  35. <artifactId>spring-boot-starter-web</artifactId>
  36. </dependency>
  37. <dependency>
  38. <groupId>net.sourceforge.nekohtml</groupId>
  39. <artifactId>nekohtml</artifactId>
  40. <version>1.9.22</version>
  41. </dependency>
  42. <!-- thymeleaf -->
  43. <dependency>
  44. <groupId>org.springframework.boot</groupId>
  45. <artifactId>spring-boot-starter-thymeleaf</artifactId>
  46. </dependency>
  47. <dependency>
  48. <groupId>org.springframework.boot</groupId>
  49. <artifactId>spring-boot-starter-jdbc</artifactId>
  50. </dependency>
  51. <!-- https://mvnrepository.com/artifact/mysql/mysql-connector-java -->
  52. <dependency>
  53. <groupId>mysql</groupId>
  54. <artifactId>mysql-connector-java</artifactId>
  55. <version>5.1.45</version>
  56. </dependency>
  57. <dependency>
  58. <groupId>cn.com.broadtech.sharecore</groupId>
  59. <artifactId>share_core</artifactId>
  60. <version>1.3.9</version>
  61. </dependency>
  62. <dependency>
  63. <groupId>com.alibaba</groupId>
  64. <artifactId>druid</artifactId>
  65. <version>1.0.25</version>
  66. </dependency>
  67. <dependency>
  68. <groupId>com.broadtech.middleware.final</groupId>
  69. <artifactId>commons</artifactId>
  70. <version>0.0.1</version>
  71. </dependency>
  72. </dependencies>
  73. <dependencyManagement>
  74. <dependencies>
  75. <dependency>
  76. <groupId>org.springframework.cloud</groupId>
  77. <artifactId>spring-cloud-dependencies</artifactId>
  78. <version>Edgware.RELEASE</version>
  79. <type>pom</type>
  80. <scope>import</scope>
  81. </dependency>
  82. </dependencies>
  83. </dependencyManagement>
  84. <build>
  85. <plugins>
  86. <!--
  87. <plugin>
  88. <groupId>org.springframework.boot</groupId>
  89. <artifactId>spring-boot-maven-plugin</artifactId>
  90. <configuration>
  91. <executable>true</executable>
  92. <mainClass>com.broadtech.bdvmonitor.BdvmonitorWebApplication</mainClass>
  93. </configuration>
  94. </plugin>
  95. <plugin>
  96. <artifactId>maven-compiler-plugin</artifactId>
  97. <configuration>
  98. <source>1.8</source>
  99. <target>1.8</target>
  100. </configuration>
  101. </plugin>
  102. -->
  103. <plugin>
  104. <groupId>org.apache.maven.plugins</groupId>
  105. <artifactId>maven-jar-plugin</artifactId>
  106. <version>2.6</version>
  107. <configuration>
  108. <archive>
  109. <manifest>
  110. <addClasspath>true</addClasspath>
  111. <classpathPrefix>lib/</classpathPrefix>
  112. <mainClass>com.broadtech.bdvmonitor.BdvMonitorWebappApplication</mainClass>
  113. </manifest>
  114. </archive>
  115. </configuration>
  116. </plugin>
  117. <plugin>
  118. <groupId>org.apache.maven.plugins</groupId>
  119. <artifactId>maven-dependency-plugin</artifactId>
  120. <version>2.10</version>
  121. <executions>
  122. <execution>
  123. <id>copy-dependencies</id>
  124. <phase>package</phase>
  125. <goals>
  126. <goal>copy-dependencies</goal>
  127. </goals>
  128. <configuration>
  129. <outputDirectory>${project.build.directory}/lib</outputDirectory>
  130. </configuration>
  131. </execution>
  132. </executions>
  133. </plugin>
  134. </plugins>
  135. </build>
  136. </project>

cmd 先找到workplace 路径

然后执行  mvn clean package


 

打包成功后

 

 

如果依赖其他工程,请先mvn  clean install 其他工程(注意是parent 路径),这样会把包编译到maven仓库中, 你在项目用,直接引用。

  1. <dependency>
  2. <groupId>com.broadtech.middleware.final</groupId>
  3. <artifactId>commons</artifactId>
  4. <version>0.0.1</version>
  5. </dependency>

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小小林熬夜学编程/article/detail/307967
推荐阅读
相关标签
  

闽ICP备14008679号