前言:
有时候在项目开发中,需要很多依赖的 jar 包,其中依赖的 jar 包也会依赖其他的 jar 包,导致jar 包的管理很容易不全,以下有两种方法可以规避这个问题。
一、在pom.xml 文件中配置,将依赖的 jar 包放到指定的文件夹中
在 pom.xml 的 build-plugins 节点上添加以下配置即可
org.apache.maven.plugins
maven-dependency-plugin
3.0.1
copy-dependencies
package
copy-dependencies
${project.build.directory}/lib
false
false
true
二、将项目打jar 包时,将依赖的 jar 包一起并入到项目 jar 包中
在 pom.xml 的 build-plugins 节点上添加以下配置即可
org.apache.maven.plugins
maven-assembly-plugin
3.0.0
jar-with-dependencies
make-assembly
package
single