在WTP(Eclipse) tomcat服务器中部署war文件
我有一个 Maven 构建 Java 项目。 我的战争文件名是:test-1.0-SNAPSHOT.war 我在 Eclipse 中使用 M2E 插件。 我已经运行目标mvn package。
在 eclipse indigo 3.7 中添加了服务器作为 tomcat 版本 7。服务器已启动。但是我的war文件没有部署在服务器中。
我尝试右键单击 tomcat 服务器并添加删除...,它说“没有可以从服务器添加或删除的资源”。
如何在 eclipse WTP tomcat 服务器中部署我的 war 文件?我需要运行任何 Maven 目标吗?
I have a maven build Java project.
My war file name is: test-1.0-SNAPSHOT.war
I am using M2E plugin in Eclipse.
I have run target mvn package.
Added server as tomcat version 7 in eclipse indigo 3.7. Server started. But my war file didn't deployed in the server.
I have tried by right clicking tomcat server and Add remove..., it says "there is no resources that can be added or removed from the server".
How can i deploy my war file in the eclipse WTP tomcat server?. Do i need to run any maven target?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
确保您的 Eclipse 实例中安装了“Maven Integration for WTP”。
首先检查它是否可以通过
如果由于某种原因这不起作用,您可以从这个更新站点获取 WTP 集成(这是我当前使用的版本):
<一href="https://repository.sonatype.org/content/repositories/forge-sites/m2eclipse-wtp/0.13.0/S/0.13.0.20110623-0455" rel="noreferrer">https://repository.sonatype.org/content/repositories/forge-sites/m2eclipse-wtp/0.13.0/S/0.13.0.20110623-0455
此集成执行生命周期映射maven-war-plugin 到 m2e 架构中。
安装 WTP 集成后,您必须重新启动 eclipse,重新启动后,右键单击您的 Web 应用程序项目并选择:Maven->更新项目配置...
另外,我建议在此运行干净的构建时间。
最后但并非最不重要的一点是,删除并重新创建 Tomcat 服务器配置(我不知道为什么,但当我切换到 m2e 时,我不得不这样做很多次)。
Make sure that you have "Maven Integration for WTP" installed in your Eclipse instance.
First check if it's available through
If for whatever reason this does not work, you can get WTP integration from this update site (that's the version I am currently using):
https://repository.sonatype.org/content/repositories/forge-sites/m2eclipse-wtp/0.13.0/S/0.13.0.20110623-0455
This integration does a lifecycle mapping of maven-war-plugin into m2e architecture.
Once you've installed the WTP integration, you must restart eclipse and once it's restarted, right click on your web app project and choose: Maven->Update Project Configuration...
Also, I would advise to run a clean build at this time.
Last, but not least, delete and recreate your Tomcat server configuration (I don't know why, but I had to do it quite a few times when I switched to m2e).
我认为 Eclipse 没有将您的项目识别为 Web 应用程序,要确认此
打开以在 Eclipse 上打开 J2ee 透视图,如果您打开应用程序的项目文件夹,您应该看到(部署描述符)
如果您没有看到它,则您的应用程序不是 Web 应用程序涉及 eclipse
选择项目==>属性==>项目方面==>确保选中动态 Web 模块复选框
如果您这样做,本地 tomcat 服务器将添加您的应用程序何时添加删除项目
I think eclipse is not recognizing your project as a web app, To confirm this
Open to do open J2ee perspective on your eclipse, If you open the project folder of your app, You should see (Deployment Descriptor)
If you don't see it, your app is not web app as far as eclipse is concerned
Select Project ==> Properties ==> Project Facets ==> make sure Dynamic Web Module check box is checked
If you do that the local tomcat server will add your app when do add remove projects
我认为 Eclipse 没有将您的项目识别为 Web 应用程序,请通过命令 mvn eclipse:eclipse -Dwtpversion=2.0 将您的项目转换为 Web 应用程序,并尝试在 Eclipse 配置的 tomcat 中部署,它将工作。
I think eclipse is not recognizing your project as web app,convert your project into web app by command mvn eclipse:eclipse -Dwtpversion=2.0 and try to deploy in Eclipse configured tomcat,it will work.
如果您有 Eclipse 3.5 或更高版本,您应该确保您同时拥有 m2eclipse ( m2e for 3.7) 安装的插件及其 WTP 插件。有了这些,您就不需要手动更改配置。
您是否尝试过从命令行构建项目并手动将其部署到 Tomcat 中?
顺便问一下,您读过这篇wiki 帖子吗?它有点旧,但可能仍然相关。
If you have Eclipse 3.5 or above you should ensure that you have both the m2eclipse (m2e for 3.7) plugin installed and its WTP add-on. With these you shouldn't need to change your configuration by hand.
Did you try to build your project from the command line and deploy it in Tomcat by hand?
By the way, have you read this wiki post? It's a bit old, but it may still be relevant.
为 Prasanna 添加 2 美分,这是一个美妙的解决方案。
我意识到构建 Maven 战争文件“mvn package”只是创建 .war 文件,但 Eclipse 并没有拾取该战争,而是部署其应用程序战争的某些内部版本。
我发现服务器>浏览部署位置..在 Eclipse 服务器视图中..它被带到一些抽象位置,例如“C:\Programs\workspaceSTS.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps”,
我可以在其中看到我的部署了爆炸的应用程序,但它没有任何 /classes 文件夹,只有有限的文件。
使用 Prasanna 的方法,我意识到 eclipse 现在正在部署完全爆炸的 .war。
所以发生这种情况是因为将方面更改为动态 Web 模块实际上已填充“R-click 项目 > 属性 > 部署程序集”
这个Web 部署程序集窗口仅告诉 Eclipse 部署什么、不部署什么。因此,即使您的项目未设置为动态 Web 模块,并且如果您正确配置“Web 部署程序集”值,Eclipse 也会将应用程序正常部署到 Tomcat/服务器。
Adding 2 cents to Prasanna wonderful solution.
I realized that building maven war files "mvn package" was just creating .war file but eclipse was not picking up that war but was deploying its some internal version of it's app war.
I found that server > Browse Deployment Location.. in Eclipse server view .. it was taking to some abstract location like "C:\Programs\workspaceSTS.metadata.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps"
Where I could see my exploded app deployed but it was not having any /classes folder just limited files.
Using Prasanna's method I realized that eclipse now was deploying full exploded .war now.
So this was happening coz changing the facets to Dynamic Web Module has actually populated "R-click project > Properties > Deployment Assembly "
This Web Deployment Assembly window only tells eclipse what to deploy and what not. So even if your project is NOT setup as Dynamic Web Module , and still if you configure "Web Deployment Assembly" values properly , eclipse will deploy the app fine to Tomcat/ Server.