There is (or was) an issue with Maven4MyEclipse when use IDE to run application or JUnit test. The problem that I encountered was that when I try to run application or JUnit test by using IDE tool, I got ClassNotFoundException, however, everything is fine when using “Maven Test”. I can not remember the exact steps to recreate the problem, but the problem was most likely due to Java Build Path.
If you see your project has both target and target-eclipse, it is very likely you will run into this kind of problem. What you can do is right click on the project, and then select Properties, then go to “Java Build Path”. In the menu, change the default output folder to ProjectName/target/classes. If your project follows standard structure, then the output folder for ProjectName/src/main/java should be changed to ProjectName/target/classes, and the output folder for ProjectName/src/test/java should be changed to ProjectName/target/test-classes. At this point, you can delete target-eclipse folder. One thing that I need to mention is that MyEclipse doesn’t create web project that follows the standard maven structure. I always change the structure and pom to follow standard maven structure, so the above steps can apply to the web project as well.
After the Java Build Path is all set, you should be able to run maven clean follow by project/clean (with build automatically enabled), then you should be able run application/JUnit test from IDE.
Maven clean will delete target folder and all the generated class files, and project/clean (with build automatically enabled) will recreate the target folder with most up-to-dated classes files.
Hope this can help.