Search code examples
eclipsemavenm2eclipse

Strange issue between Eclipse Mars and Maven


Some context

I am creating a Spring Boot base code application that is in fact separated in three projects/modules:

springbase-core

contains:

  • custom annotations
  • custom exceptions
  • custom generic Spring components
  • model (entities)
  • metamodels (generated by maven through the maven-processor-plugin)
  • utils

depends on: nothing

springbase-data

contains:

  • data related annotations
  • services
  • repositories
  • data related util classes

depends on: springbase-core

springbase-web

  • controllers
  • form classes
  • filters
  • listeners
  • interceptors
  • JSPs
  • JSP Tags
  • etc.

depends on: springbase-data, springbase-core

The problem I am having is that if I have springbase-core in my Eclipse workspace, I'm not able to import metamodels in repository classes in springbase-data. If I remove the springbase-core project (where metamodels reisde) from my Eclipse workspace, it works.

I have also tried copying springbase-core-0.0.1-SNAPSHOT.jar from my .m2 repository, directly at the root of my project (and taking care of adding it in .classpath), and I was able to import metamodels.

When opening springbase-core-0.0.1-SNAPSHOT.jar with WinZip, I can see the metamodels. Building springbase-core with Maven also shows the generated metamodels under /target/metamodel as configured in my pom.xml.

Looks like a glitch between Eclipse and Maven.

Any thoughts?


Solution

  • Here is a solution to my problem: Right click on all projects, click on Maven, and then Disable Workspace Resolution.

    That way Maven is going to look for the dependency only from .m2, regardless of what's in my workspace.