Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Does Maven resolve dependencies of dependencies?

The current project I’m participating in has such structure:

  • Project 1
    • depends on Project2 in pom
    • checks if object is instanceof SomeClass (mentioned below)
  • Project 2
    • depends on spring-boot-starter-web-services in pom
    • is imported into Project1 as a .jar file through IntelliJ IDEA project settings
    • has a class, SomeClass that extends org.springframework.ws.client.core.support.WebServiceGatewaySupport

When running mvn clean package, the error below shows up:

cannot access  org.springframework.ws.client.core.support.WebServiceGatewaySupport

and the error’s line refers to where instanceof SomeClass is written.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Checking the External Libraries in IntelliJ IDEA, seems like libraries related to spring-boot-starter-web-services simply just didn’t show up. Adding spring-boot-starter-web-services in project1’s pom fixes this but it seems confusing because project2, which project1 depends on, already has that in its pom.

Is this intended behaviour of Maven? Does Maven install dependencies of dependencies? Or is there something I still need to configure to make this work?

>Solution :

It depends: usually maven cares for transitive dependencies.

But if your Project2 is

  1. neither available in a remote Repo (because you didn’t mvn deploy it)
  2. nor in the local Repo (because you didn’t mvn install)
  3. nor you have it as sibling module in a modularized project

or you didn’t update (in the cases of 1 and 2) it for a long time there, maven could try to work with an old version of the poms that might not yet contain that dependencies.

Another source of problems could be if Project 2 declares its dependencies in the maven scope of provided.

And you wrote that Project 1 depends on Project 2 "through IntelliJ IDEA project settings". This is not sufficient for maven to resolve dependencies, you have to declare the dependency in the maven pom.xml!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading