问题
I have a mavenized project with dependencies upon 4 others mavenized projects that my team is currently working on. We have "workspace resolution" enabled.
If I publish to Tomcat, jars are not available for the 4 projects so I see all sorts of NoClassDefFoundError exceptions. I don't see any problems with JUnit testing or packaging. (I run the package goal and the resulting war file includes the SNAPSHOT jars that I expect.)
I see a lot of people advocating for using workspace resolution, but if we need to test in Tomcat should we disable this? Or what else might I be missing?
We use Eclipse Helios, the m2eclipse plugin, Maven 3.0.3. I even installed m2extras to see if that helped, but I didn't see any difference.
Thanks
回答1:
You can get this setup to work (we have been working with the same toolchain and setup here) if you can live with some manual refreshes, after you have been using m2eclipse goals to build.
The problem is, that not all external changes via m2eclipse builds to workspace projects are synched correctly to your deployed web application in tomcat.
So if you are experiencing NoClassDefFoundError exceptions after building via m2eclipse the following should help (not all are necessary everytime):
- Do a Project/Clean on your maven projects
- Do a Refresh (F5) on your maven projects
- Clean the deployed web application (Server Context menu)
Yes, it is cumbersome but one can live with it.
回答2:
- Remove the dependency project from the workspace.
- Delete .settings directory and .project files.
- Import the project again.
- Update maven dependencies in all projects.
来源:https://stackoverflow.com/questions/4683051/maven-workspace-resolution-missing-jars-for-local-tomcat-testing