I\'m working on a project that has lots of different Maven projects. I\'ve been doing a bunch of JUnit testing on these projects, and usually this goes well. I open up Eclipse
Several of the existing answers should work, but those suggesting to add a Java facet will only work if your project already is of (or you want to convert it to) a faceted nature, and the one suggesting you change your pom.xml
will only work if you then re-import your project as a maven project.
If you'd like to "fix" your existing project, i.e. add a Java nature without converting it to faceted form and without deleting and re-importing, just edit your .project
file (externally, or with the Navigator view in eclipse, as it won't show up in your package explorer) and add the java builder and java nature to the existing maven builder/nature:
yourprojectname
org.eclipse.jdt.core.javabuilder
org.eclipse.m2e.core.maven2Builder
org.eclipse.jdt.core.javanature
org.eclipse.m2e.core.maven2Nature
Note the different capitalisation (javabuilder but maven2Builder, javanature but maven2Nature).
As soon as you save, it should re-build automatically. You may have to manually add any source folders (Project properties
-> Java Build Path
-> Source
tab -> Add Folder...
.