![4ff5500a3bdecc2226175079adcafea2.png](https://i-blog.csdnimg.cn/blog_migrate/1965a02317ae79d7bbd869885f471ac8.jpeg)
本地打包项目时,在pom.xml上添加maven-dependency-plugin插件可以分析项目依赖的jar包,并生成jar报告。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy-dependencies</id>
<phase>package</phase>
<goals>
<goal>copy-dependencies</goal>
</goals>
<configuration>
<outputDirectory>
${project.build.directory}/lib/
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
添加插件后,选择dependency:analyze-report
![153c6296e05721b093ab07b4a7d300f5.png](https://i-blog.csdnimg.cn/blog_migrate/c0e7a11fa9f48dfaf86a8010f99d01ec.jpeg)
生成的报告
![87b35c9d3365aa8df01f46f7ca899b66.png](https://i-blog.csdnimg.cn/blog_migrate/896d29b1ead0654fde38f7f01bda65ec.png)
这个插件配置不仅分析jar包依赖,同时把app.jar里的jar包复制出来了,在target目录下生成了一个lib目录,把所有的app.jar里面的jar包都复制到这里面。这样后面使用owasp dependency-check插件时,扫描jar包时就会扫描lib目录下的jar。否则会扫描app.jar里面的jar包。
jeinkins上构建项目时如果想使用maven-dependency-plugin插件分析项目jar包依赖,只需在maven的打包命令后添加dependency:analyze-report即可,不需要在pom.xml中配置插件
mvn clean package -Dmaven.test.skip=true -pl xx.xx.xx:模块名 -am dependency:analyze-report
项目构建后,可在相应的模块的工作空间下看到生成的jar包依赖报告
![0387c1f75fe97c5c62056f90408f3f21.png](https://i-blog.csdnimg.cn/blog_migrate/83cbc91687f0c5c107027794e9bb2c9c.png)