Can someone explain Maven 2 (or 3) dependency resolution for me?

I used Maven before in several projects, but we already set up someone else. I quickly understood the basic concepts (groups, artifacts and versions for cans, local and remote repositories), so I assumed that if asked, I could easily create a new project from scratch.

This was not the case when I was dealing with several modules that are dependent on each other. I bumped into maven docs, but they are either too brief or too technical (sometimes I feel like Maven people write this for themselves and not for Maven users). Therefore, I ask for help from the community.

Here's a typical scenario:

Three repositories:

I am creating a normal Java EE project consisting of one EJB banner with the corresponding client bank, web module and JPA module (I like to keep my entities and all db connections separate from business logic). This gives me 5 projects in my IDE:

  • myapp-ear
  • myapp-ejb
  • myapp-ejb-client
  • myapp-jpa
  • myapp-web

myapp-jpaused myapp-ejband myapp-web. myapp-ejb-clientcontains business interfaces for my EJBs.

How can I do all this? I suspect that I need some kind of parent project, but I'm not sure how to organize inter-task resolution of dependencies. For example: currently, when I specify

<dependency>
  <groupId>com.mycompany.myapp</groupId>
  <artifactId>myapp-jpa</artifactId>
  <version>0.1-SNAPSHOT</version>
</dependency>

in myapp-ejb pom.xml maven , .jar . , Maven : (

, Eclipse NetBeans.

+3
1

, . , . ( ) , dependencyManagement. pom , .

( ) , Eclipse, , " Maven", m2Eclipse .

, .

+3

Source: https://habr.com/ru/post/1787219/


All Articles