从 Eclipse 在 Tomcat 上运行 Maven 项目
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12895734/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Running Maven project on Tomcat from Eclipse
提问by Reddy
I have a Maven Project in Eclipse. I want to deploy it in my local tomcat server and run it like normal J2EE projects.
我在 Eclipse 中有一个 Maven 项目。我想将它部署在我本地的 tomcat 服务器中并像普通的 J2EE 项目一样运行它。
But What i found is in tomcat add/remove projects option, no project is shown. Right click on maven project and run as doesn't have Run on Server option or may be I am missing something.
但是我发现在 tomcat 添加/删除项目选项中,没有显示任何项目。右键单击 maven 项目并运行,因为没有在服务器上运行选项,或者可能是我遗漏了什么。
All I am looking for running Maven projects (from eclipse, no command prompt or manual copy paste of wars) in local Tomcat server just like normal J2EE projects without modifying pom.xml (seriously I don't want to modify this)
我正在寻找在本地 Tomcat 服务器中运行 Maven 项目(来自 eclipse,没有命令提示符或手动复制粘贴War)就像普通的 J2EE 项目一样而不修改 pom.xml(说真的我不想修改这个)
回答by Aleksandr M
In Eclipse Maven Integration for WTP
must be installed. Also this project must be configured with web nature.
在 Eclipse 中Maven Integration for WTP
必须安装。此外,此项目必须配置为 Web 性质。
UPDATE
更新
To turn on web nature in your project properties -> Project Facets -> Convert to faceted form... -> Dynamic Web Module -> OK
在你的项目属性中打开 web 性质 -> Project Facets -> Convert to faceted form... -> Dynamic Web Module -> OK
回答by Vijay B
To complete AleksandrM answer, if someone wants to make their existingeclipse web project maven aware in Eclipse, highlight the project in explorer -> Right mouse click and select Configure-> Convert To Maven Project
要完成AleksandrM 答案,如果有人想让他们现有的Eclipse Web 项目在 Eclipse 中识别,请在资源管理器中突出显示该项目 -> 鼠标右键单击并选择配置->转换为 Maven 项目
回答by davidfmatheson
There can be a few reasons why you don't see the project in the Add/Remove projects dialog for Tomcat. Verify the following:
在 Tomcat 的“添加/删除项目”对话框中看不到该项目的原因可能有多种。验证以下内容:
- You have
m2e
installed (http://eclipse.org/m2e/download/) - You have
m2e-wtp
installed (http://www.eclipse.org/m2e-wtp/download/) - Your Maven project imported as a
Dynamic Web Application
. Look for aDeployment Descriptor
entry when you expand the project, it should be somewhere in the first few entries. It is the second one down for me on Eclipse Juno. Not there? It's probably not a web app. Go back and verify 1 & 2, then remove and re-import your project. - Make sure that your web application is not too new for the version of Tomcat that you are using. Right-click the project and go to
Properties
>Project Facets
. Look forDynamic Web Module
and check the version. If this version is too new for your Tomcat version, Eclipse won't let you add it. For instance, yourDynamic Web Module
version is 3.0 and you're using Tomcat 6.
- 您已
m2e
安装 (http://eclipse.org/m2e/download/) - 您已
m2e-wtp
安装 (http://www.eclipse.org/m2e-wtp/download/) - 您的 Maven 项目作为
Dynamic Web Application
.Deployment Descriptor
展开项目时查找条目,它应该在前几个条目中的某个位置。这是我在 Eclipse Juno 上的第二个失败。不在那里?它可能不是网络应用程序。返回并验证 1 和 2,然后删除并重新导入您的项目。 - 确保您的 Web 应用程序对于您正在使用的 Tomcat 版本来说不是太新。右键单击该项目并转到
Properties
>Project Facets
。查找Dynamic Web Module
并检查版本。如果此版本对于您的 Tomcat 版本来说太新,Eclipse 将不允许您添加它。例如,您的Dynamic Web Module
版本是 3.0,而您使用的是 Tomcat 6。