当将webapp添加到tomcat服务器时,默认生命周期为m2e [英] m2e default lifecycle when adding webapp to tomcat server

查看:102
本文介绍了当将webapp添加到tomcat服务器时,默认生命周期为m2e的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用m2eclipse一段时间,我突然问自己这个非常基本的问题:



当我拖放时,哪些maven阶段是生命周期的一部分一个webapp进入我的tomcat服务器?



我认为它必须像干净的包PLUS将包的部署到tomcat webapp目录。
但是我找不到准确定义它的文章。
此外,这个默认行为是否可以覆盖?



我错了吗?



提前感谢你是对的 - 你将会经历(无论你是否使用 m2eclipse 或命令行版本)





通过运行

  mvn clean package 

进一步引用 doc 重点我的),


默认情况下,有些阶段的目标是绑定到它们的。而对于默认的
生命周期,这些绑定取决于包装值(
中应该是 war


所以 maven-war-plugin 可以处理您的包装在您的情况下部署(不要将 Maven 部署)与Tomcat实例混淆。



尽管您通常希望将安装到您的本地 m2 存储库和部署到远程的 m2 存储库中的工件( *。war )在本地以外的环境中可用。为此,您将根据需要进一步进入默认生命周期。






此外, tomcat7-maven-plugin 可以帮助您在任何tomcat服务器上部署工件,您只需将正确的目标附加到适当的阶段。阅读更多关于使用插件的信息 here


I'm using m2eclipse for a while, and I suddenly ask myself this very basic question:

Which maven phases are part of the lifecycle when I drag and drop a webapp into my tomcat server?

I assume it must be something like "clean package" PLUS a deployment of the package into the tomcat webapp directory. But I can't find an article defining it precisely. Also, is this default behaviour overridable?

Am I totaly wrong?

Thanks in advance!

解决方案

You're right - you will typicaly go through (regardless of whether you use the m2eclipse or the commandline version)

  • the clean lifeycle (refer to the standard phases in this lifecycle here)

  • the default lifeycle, particularly the phases from validate thru package (again, refer to the standard phases in this lifecycle here)

by running

mvn clean package

Quoting the doc further (emphasis mine),

Some phases have goals bound to them by default. And for the default lifecycle, these bindings depend on the packaging value (which in your case should be war).

So the maven-war-plugin handles the packaging for you to deploy (not to be confused with the Maven deploy) it to a tomcat instance in your case.

Although you will usually want to install it to your local m2 repository and deploy it to a remote m2 repository for the artifact (*.war) to be available in environments other than your local. For that, you will want to go further into the default lifecycle depending on your need.


Also, the tomcat7-maven-plugin can help you deploy the artifact on any tomcat server, you will just need to attach the right goal to the appropriate phase. Read more about the use of the plugin here.

这篇关于当将webapp添加到tomcat服务器时,默认生命周期为m2e的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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