相关命令
mvn dependency:help
mvn dependency:analyze
mvn dependency:tree
mvn dependency:list
mvn dependency:tree -DoutputType=graphml -DoutputFile=dependency.graphml
mvn dependency:resolve-plugins
mvn dependency:copy-dependencies -DoutputDirectory=lib
mvn dependency:copy-dependencies -DoutputDirectory=lib -DincludeScope=compile
mvn dependency:analyze -DignoreNonCompile
[WARNING] Used undeclared dependencies found:
[WARNING] org.springframework:spring-web:jar:5.0.5.RELEASE:compile
[WARNING] org.springframework.boot:spring-boot-test:jar:2.0.1.RELEASE:test
[WARNING] javax.validation:validation-api:jar:2.0.1.Final:compile
[WARNING] org.springframework.boot:spring-boot:jar:2.0.1.RELEASE:compile
[WARNING] org.apache.tomcat.embed:tomcat-embed-core:jar:8.5.29:compile
[WARNING] org.springframework:spring-test:jar:5.0.5.RELEASE:test
[WARNING] org.springframework.boot:spring-boot-autoconfigure:jar:2.0.1.RELEASE:compile
[WARNING] org.springframework:spring-webmvc:jar:5.0.5.RELEASE:compile
[WARNING] junit:junit:jar:4.12:test
[WARNING] org.springframework:spring-core:jar:5.0.5.RELEASE:compile
[WARNING] org.springframework:spring-context:jar:5.0.5.RELEASE:compile
[WARNING] Unused declared dependencies found:
[WARNING] org.springframework.boot:spring-boot-starter-web:jar:2.0.1.RELEASE:compile
[WARNING] org.webjars:bootstrap:jar:3.3.7-1:compile
[WARNING] org.webjars:jquery:jar:2.1.4:compile
[WARNING] org.webjars:webjars-locator:jar:0.32-1:compile
[WARNING] org.webjars:materializecss:jar:0.96.0:compile
[WARNING] org.springframework.boot:spring-boot-starter-thymeleaf:jar:2.0.1.RELEASE:compile
[WARNING] org.thymeleaf:thymeleaf-spring4:jar:3.0.9.RELEASE:compile
[WARNING] org.mybatis.spring.boot:mybatis-spring-boot-starter:jar:1.3.2:compile
Unused declared dependencies found:指项目中未使用的,但是显示声明的依赖,但是对于这样的依赖,不能直接删除,要仔细分析。因为 dependency:analyze 只会分析编译主代码和测试代码用到的依赖,一些执行测试和运行时需要的依赖是发现不了的。但是很显然有些依赖是必须的,不能删除。所以要小心寻找无用的依赖信息,然后再删除。
将 Unused declared dependencies found 的包去掉之后,变为如下
[WARNING] Used undeclared dependencies found:
[WARNING] org.springframework.boot:spring-boot-test:jar:2.0.1.RELEASE:test
[WARNING] org.springframework.boot:spring-boot:jar:2.0.1.RELEASE:test
[WARNING] org.springframework:spring-test:jar:5.0.5.RELEASE:test
[WARNING] org.springframework.boot:spring-boot-autoconfigure:jar:2.0.1.RELEASE:test
[WARNING] junit:junit:jar:4.12:test
[WARNING] org.springframework:spring-core:jar:5.0.5.RELEASE:test
[WARNING] org.springframework:spring-context:jar:5.0.5.RELEASE:test
mvn dependency:analyze
[WARNING] Used undeclared dependencies found:
[WARNING] org.springframework.boot:spring-boot-test:jar:2.0.1.RELEASE:test
[WARNING] org.springframework.boot:spring-boot:jar:2.0.1.RELEASE:test
[WARNING] org.springframework:spring-test:jar:5.0.5.RELEASE:test
[WARNING] org.springframework.boot:spring-boot-autoconfigure:jar:2.0.1.RELEASE:test
[WARNING] junit:junit:jar:4.12:test
[WARNING] org.springframework:spring-core:jar:5.0.5.RELEASE:test
[WARNING] org.springframework:spring-context:jar:5.0.5.RELEASE:test
[WARNING] Unused declared dependencies found:
[WARNING] mysql:mysql-connector-java:jar:5.1.46:runtime
[WARNING] org.springframework.boot:spring-boot-starter-test:jar:2.0.1.RELEASE:test
版权声明
本文仅代表作者观点,不代表百度立场。
本文系作者授权百度百家发表,未经许可,不得转载。

