全国免费服务热线:

18982081108
✕

成都弹性云服务器,成都高防云服务器,互联网数据服务,成都祈钰瑶

Maven项目实现打Jar包并添加依赖-创新互联

这期内容当中小编将会给大家带来有关Maven项目实现打Jar包并添加依赖,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。

成都创新互联公司主营王屋网站建设的网络公司,主营网站建设方案,app开发定制,王屋h5微信小程序开发搭建,王屋网站营销推广欢迎王屋等地区企业咨询

使用maven-dependency-plugin插件

子项目中的pom.xml文件中,添加以下maven-dependency-plugin依赖,这个maven-dependency-plugin依赖的作用就是自动拷贝jar包到target目录

  这是我的Maven子项目打包,指定了将它的依赖的父项目中的jar包拷贝到target下的lib目录

<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>
        <!-- ${project.build.directory}为Maven内置变量,缺省为target -->
        <outputDirectory>${project.build.directory}/lib</outputDirectory>
        <overWriteReleases>true</overWriteReleases>
        <overWriteSnapshots>true</overWriteSnapshots>
        <overWriteIfNewer>true</overWriteIfNewer>
      </configuration>
    </execution>
  </executions>
</plugin>