开发者

M2Eclipse can't find dependencies when they are projects in the same workspace

开发者 https://www.devze.com 2023-01-31 05:30 出处:网络
I know there are various known issues with the M2eclipse plugin and I guess this is just one of them. Hopefully someone is aware of a solution or workaround.

I know there are various known issues with the M2eclipse plugin and I guess this is just one of them. Hopefully someone is aware of a solution or workaround.

We have like 30 projects in our workspace but for clarity lets assume there are only 2: A en B.

B includes A as a dependency in the pom.xml of B. The problem we have is that in eclipse the classes of A can't be found so you get compilation errors. However, if you 'mvn install' A to deploy it in the local repository and the close project A then everything is fine; no compilation errors. So, if A exists in the project M2Eclipse does not seem to be able to correctly set the classpath in eclipse.

To make things stranger, we a开发者_开发技巧lso have project C that also depends (in exactly the same way as B) on project A but here we have no compilation errors. We can't identify anything meaningful difference between project B or C; as said, they include A in the same manner.

thanks for your help, Stijn

P.S. I'm using version 0.10.2.20100623 of the plugin


I've experienced this behavior before, and it has occurred for me in the past when I imported or checked out the maven projects separately.

Prerequisite: make sure you have m2extras installed before you check out a multi-module Maven project: update site

First thing to try: right-click each project and choose Maven -> update project configuration. The plugin might be smart enough to detect that it could be building project references between the projects.

Second thing to try (if your 30 projects are all submodules off one root): this would be easiest, because you could use the SCM integration of m2eclipse to do a "Checkout as Maven Project..." on the root pom. M2eclipse would make a project for the superpom and for each submodule, with project references built appropriately.

Third thing to try: I'd try manually creating project references in the project settings of each project to mirror their interdependencies. It'd be a lot of work, and unless you check in your eclipse .project/.settings (eww), it would have to be done individually for each working copy.


RESOLVED

finally, after agonizing hours I found the cause. I was focussing on the .classpath and the .settings files but the problem was located in the .project file. This file in project A was missing following entry in the tag natures:

<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>

Adding this resolved the issues.

0

精彩评论

暂无评论...
验证码 换一张
取 消