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)
- depends on
- 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 extendsorg.springframework.ws.client.core.support.WebServiceGatewaySupport
- depends on
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.
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?
CodePudding user response:
It depends: usually maven cares for transitive dependencies.
But if your Project2 is
- neither available in a remote Repo (because you didn't
mvn deploy
it) - nor in the local Repo (because you didn't
mvn install
) - 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!