Eclipse maven-enabled web app references workspace projects, but those are not deployed when running Tomcat server

人走茶凉 提交于 2019-12-10 12:59:28

问题


I have a web application (Eclipse's Dynamic Web App) which uses Maven (m2e-wtp) for the build and dependencies management. This web app's POM references a few other projects in my workspace, which happen to be eclipse plugins built with maven as well (built using Tycho), and also other third party libraries which come from Maven's repository.

Everything works fine when I run maven from the CLI. All dependencies are included in the WEB-INF/lib directory just as expected.

The problem is when I attempt to run the project using Eclipse. I run the app in a configured Tomcat server inside Eclipse, but the referenced projects in my workspace are not added to the deployed war.

I tried adding them to the Deployment Assembly (under project preferences), and that works perfectly, but those settings get wiped out by m2e every time the maven configurations are updated. I read in a few places that we should not manually add entries there since all dependencies should be managed by m2e...

The question is: How to make Eclipse add the workspace project dependencies to the WEB-INF/lib of my web app when I run it from Eclipse?

I'm using Eclipse J2EE 4.3.1 (Kepler SR1).

I also tried right-clicking the project and selecting Export -> WAR file, but the exported WAR file doesn't include the referenced workspace projects either. I'm assuming the issue is affecting both cases.

This is extremely annoying ans is slowing me down quite a bit.. at this time I have to re-add the projects to the Deployment Assembly page several times a day to keep it going...

UPDATE: The workspace projects I added as dependencies in the POM appear in the list of Referenced Projects, under the project's properties. But when I expand the Maven Dependencies in the Project Explorer, the workspace project dependencies are missing from the list! Only the ones in the Maven repository show up. They local ones seem to be silently ignored...


回答1:


I had similar problem because I created the project outside eclipse, and them imported it. What worked for me was to add the right project facet: Project context menu -> properties -> Project Facets -> Dynamic Web Module (choose right version). I was using Eclipse ADT (version 4.2.0), but, to avoid having multiple installations, I use the same eclipse for Android and other kind of apps.



来源:https://stackoverflow.com/questions/20750774/eclipse-maven-enabled-web-app-references-workspace-projects-but-those-are-not-d

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!