In eclipse, maven dependencies are overriding project dependencies

I have a “master project” that uses several “modules”. Modules are in pom.xml, but I also have code for modules like projects in Eclipse. I defined modules as project dependencies in both Properties and Properties> Java Build Path. I also made sure that all Eclipse projects are at the top of the Order and Export section of the Java build path.

The master project does not recognize module changes in eclipse. When I press F3 to see the code, it opens a java source from my .m2 directory. Obviously, he is ignoring my Eclipse projects. Am I missing some settings? What should I do?

+4
source share
3 answers

You do not need to add dependent projects to Project links (at least when using the m2eclipse-plugin module), just add them as dependencies on your host's pom.xml. I didn't need to touch the build path since I started using Maven in Eclipse.

Make sure that you enable workspace permission for the plugin by right-clicking on the project root → Maven → Allow workspace permission. If he says "Disable workspace permission", he is already on. You may also need to run “Update Project Configuration” in the same menu.

Thus, when you start your master project from Eclipse, any changes made to other projects will be “visible” to the wizard (and you can use hot swap at runtime even in other projects).

+6
source

If you use Maven, you pretty much want to pass Maven. Even if you configure Eclipse with Eclipse-dependent dependencies, anytime you update your project configuration using Maven, it will completely rewrite your configuration.

I highly recommend converting any of your other project build dependencies into Maven-enabled projects that can be used as Maven dependencies.

In your particular case (using Maven modules), this means that each of your modules is imported into Eclipse as projects with m2e support. m2e automatically connects to dependencies between modules and other dependent projects.

+3
source

I scratch my head why you need your modules, defined as dependencies on your top-level project. Are you trying to avoid the need to define (cross) dependencies at the module level? In any case, in accordance with other proposals, first of all put your dependencies in the right places of your POM, or run

mvn eclipse:clean eclipse:eclipse 

to update your Eclipse settings or, even better, make sure m2eclipse is installed and imports your maven projects directly into the IDE.

0
source

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


All Articles