Eclipse启用maven的Web应用程序引用工作区项目,但是在运行Tomcat服务器时不会部署这些项目 [英] Eclipse maven-enabled web app references workspace projects, but those are not deployed when running Tomcat server

查看:170
本文介绍了Eclipse启用maven的Web应用程序引用工作区项目,但是在运行Tomcat服务器时不会部署这些项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Web应用程序(Eclipse的动态Web应用程序),它使用Maven(m2e-wtp)进行构建和依赖关系管理。这个网络应用程序的POM引用了我的工作空间中的一些其他项目,这恰好是使用maven构建的eclipse插件(使用Tycho构建的)以及来自Maven存储库的其他第三方库。



当我从CLI运行maven时,一切正常。所有依赖项都按照预期的方式包含在WEB-INF / lib目录中。



问题是当我尝试使用Eclipse运行项目时。我在Eclipse中配置的Tomcat服务器中运行应用程序,但是我的工作空间中引用的项目不会添加到已部署的战争中。



我尝试将它们添加到部署程序集(根据项目首选项),并且工作正常,但是每当更新maven配置时,这些设置将被m2e消除。我读了几个地方,我们不应该手动添加条目,因为所有的依赖关系应该由m2e ...



问题是:如何使当我从Eclipse运行时,Eclipse将工作空间项目依赖关系添加到我的Web应用程序的WEB-INF / lib?



我使用的是Eclipse J2EE 4.3 (Kepler SR1)。



我也尝试右键单击项目并选择Export - > WAR文件,但导出的WAR文件不包括被引用的工作区项目也。我假设这个问题正在影响这两种情况。



这是非常烦人的,这让我放慢了一点..在这个时候我必须重新添加项目到部署组装页面,每天几次,以保持它的进行...



更新:我添加的工作区项目作为依赖关系POM显示在项目属性下的引用项目列表中。但是当我在Project Explorer中扩展Maven依赖关系时,列表中缺少工作区项目依赖关系!只有Maven存储库中的那些显示。他们当地的人似乎被忽略了...

解决方案

我有类似的问题,因为我在eclipse之外创建了项目,导入它对我有用的是添加正确的项目方面:项目上下文菜单 - >属性 - >项目方面 - >动态Web模块(选择正确的版本)。我正在使用Eclipse ADT(4.2.0版),但是为了避免多次安装,我为Android和其他类型的应用程序使用相同的eclipse。


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...

解决方案

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.

这篇关于Eclipse启用maven的Web应用程序引用工作区项目,但是在运行Tomcat服务器时不会部署这些项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆