Another case where m2e fails to import a Maven project correctly #859
Replies: 2 comments 1 reply
-
It seems like you .classpath is incorrect. Just fix it (you may use m2e to generate a fixed one) and commit a fixed version. There is no point in keeping incorrect files in the repository in a state that makes import more difficult. About the rest, please open a bug with a minimal project that reproduce the issue. |
Beta Was this translation helpful? Give feedback.
-
I think the .classpath misses the attribute on src/test/java folder to declare it's a test folder. Without it, the test dependencies from the Maven container are invisible to it. |
Beta Was this translation helpful? Give feedback.
-
I work with a bunch of Java SpringBoot services built using Maven.
Using Eclipse 2022-06.
Every once in a while I import a Maven project where someone has persisted the .project and .classpath files in git, and when I import it, it has brain damage. It often doesn't set the source directories property. In almost all of those cases, I simply move the "dot files" out of the way (rename them) and then reimport the project, and it's all fine.
Every once in a while I run into a project that m2e is consistently confused about, even though it builds fine from the command line. I'm dealing with one of those now. When I first imported it, without removing the dot files, it groked it was a Maven project, but not a Java project. I tried enabling natures and adding the Java nature, but that didn't seem to help very much. I finally just copied over the dot files with the same files from a different project that is working fine, renaming the project name in the .project file. This also "almost works". I'm now getting "cannot be resolved" errors for classes that are inside maven dependencies that even Eclipse is showing me are present.
For instance, the first compile error it shows is "BDDMockito cannot be resolved". In the source file, the import of "org.mockito.BDDMockito" has the red line underneath "org.mockito", so that means it can't find that package.
In the Project Explorer, in that project, I expanded the "Maven Dependencies" entry and scrolled through all of the dependencies until I found "mockito-core-3.3.3.jar", which is exactly the dependency that is specified in the pom.xml. I expanded that and verified that "org.mockito.BDDMockito" is certainly present in that dependency.
I've tried doing a "Maven Update". That doesn't fix it.
I checked the .metadata/.log file, and there wasn't anything significant.
Beta Was this translation helpful? Give feedback.
All reactions