3

I want to remove unnecessary dependencies from pom.xml. I have used mvn dependency:analyze and I got these results. Do I need to remove used undeclared dependencies and unused declared dependencies? May I know how can I remove dependencies from maven, so that I can build my project quickly?

[WARNING] Used undeclared dependencies found:
[WARNING]    com.fasterxml.jackson.core:jackson-annotations:jar:2.11.2:compile
[WARNING]    org.springframework:spring-beans:jar:5.2.9.RELEASE:compile
[WARNING]    junit:junit:jar:4.13:compile
[WARNING]    org.springframework:spring-jdbc:jar:5.2.9.RELEASE:compile
[WARNING]    com.sap.cloud.security.xsuaa:spring-xsuaa:jar:2.8.0:compile
[WARNING]    com.google.code.gson:gson:jar:2.8.6:compile
[WARNING]    com.zaxxer:HikariCP:jar:3.4.5:compile
[WARNING]    com.sap.cloud.instancemanager:util:jar:1.17.2:compile
[WARNING]    org.springframework:spring-core:jar:5.2.9.RELEASE:compile
[WARNING]    org.springframework.boot:spring-boot-autoconfigure:jar:2.3.4.RELEASE:compile

[WARNING] Unused declared dependencies found:
[WARNING]    com.sap.cds:cds-starter-spring-boot-odata:jar:1.17.1:compile
[WARNING]    org.apache.tomcat.embed:tomcat-embed-websocket:jar:9.0.53:compile
[WARNING]    org.apache.tomcat:tomcat-annotations-api:jar:9.0.53:compile
  • 3
    As far as I know used undeclared dependencies are those that you didn't declare in your pom.xml but are transitive dependencies of those you did declare - plus your code directly uses them. This could lead to build problems if the version of a transitive dependency changes so you might want to think about declaring them. Unused declared dependencies are those you declared in your pom.xml but your code doesn't seem to use them - they might be safe to remove but the plugin might also have missed a usage, so try and check. If they are still needed, tell Maven to ignore them in the analysis. – Thomas Dec 07 '21 at 10:59
  • 1
    I would do step by step...remove one and check your tests and go on... – khmarbaise Dec 07 '21 at 10:59
  • @Thomas Could you tell me how to remove Unused declared dependencies since they are not direct libraries in pom.xml – user3632140 Dec 07 '21 at 11:08
  • 1
    Look at your pom.xml, you should have listed them there - that's what I understand "declared" means. – Thomas Dec 07 '21 at 11:10
  • 1
    any comment from experts ? – user3632140 Dec 07 '21 at 12:11
  • Does this answer your question? [What are unused/undeclared dependencies in Maven? What to do with them?](https://stackoverflow.com/questions/4565740/what-are-unused-undeclared-dependencies-in-maven-what-to-do-with-them) – João Dias Dec 08 '21 at 14:20

0 Answers0