Problem with Eclipse and the Maven Multimodule Project

I created a Maven project with the following structure:

 + root-project
   pom.xml (pom)
   + sub-projectA (jar)
   + sub-projectB (jar)

I took the following steps:

  • mvn archetype: create -DgroupId = my.group.id -DartifactId = root-project
  • mvn archetype: create -DgroupId = my.group.id -DartifactId = sub-projectA
  • mvn archetype: create -DgroupId = my.group.id -DartifactId = sub-projectB

So, I obviously have the following elements on top-level pom.xml:

<modules> <module>sub-projectA</module> <module>sub-projectB</module> </modules> 

Last step:

 mvn eclipse:clean eclipse:eclipse 

Now, if I import the root project into Eclipse, it seems to treat my projects as resources, not java projects.

However, if I import each sub-projectA and sub-projectB child project, it looks like java projects.

This is a big problem for me because I have a deeper hierarchy. Any help would be appreciated!

+7
eclipse maven-2 multi-module
source share
3 answers

The maven eclipse plugin does NOT support nested projects, so you cannot import the root project and nested modules (unless you switch to a flat layout ).

An alternative is to use m2eclipse (and you won't have a problem with a typical nested maven tree). This is currently the preferred approach.

+4
source share

Please follow these simple steps to set up your project.

  • Download project from maven project

  • Inside ch-multi- spring -> simple parent

convert a simple-parent project to eclipse with this command

 mvn eclipse:eclipse 
  1. Import the parent element into eclipse.

  2. To launch this project

    right click on simple-webapp-> properties-> deploy assemblylly-> project-> Then add all the dependent projects.

  3. Now you can run this project.

0
source share

I had a similar problem, and here is what I did to solve it ...

I had an open parent project, as well as child projects. Children's projects will work well and no problems will be displayed, however the parent project showed the child projects as "resource folders" and they showed that they had problems.

The solution was to right-click on each of the child projects in the parent project → Properties → Resource → Check Derivatives

After that, clean / rebuild and you should be good.

0
source share

All Articles