问题
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!
回答1:
You're right - you will typicaly go through (regardless of whether you use the m2eclipse or the commandline version)
the
cleanlifeycle (refer to the standard phases in this lifecycle here)the
defaultlifeycle, particularly the phases fromvalidatethrupackage(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.
来源:https://stackoverflow.com/questions/30403197/m2e-default-lifecycle-when-adding-webapp-to-tomcat-server