|
原文:http://stackoverflow.com/questions/7801155/how-to-run-tomcat-7-using-maven-2-tomcat-plugin
This works for me: http://tomcat.apache.org/maven-plugin-2.1/
With this plugin config
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.1</version>
</plugin>
</plugins>
</build>
And running with
mvn clean install tomcat7:run
(Please note that tomcat7:run, not tomcat:run.)
Plugin documentation is here: http://tomcat.apache.org/maven-plugin-2.1/tomcat7-maven-plugin/plugin-info.html
For example, the default value of additionalConfigFilesDir is ${basedir}/src/main/tomcatconf, so if you put your configs into this directory it will be used on tomcat7:run.
mvn -X tomcat7:run prints the configration, for example:
[DEBUG](f) additionalConfigFilesDir =/workspace/webtest1/src/main/tomcatconf
[DEBUG](f) configurationDir =/workspace/webtest1/target/tomcat
...[DEBUG](f) path =/webtest1
...[DEBUG](f) port =8080[DEBUG](f) project =...:webtest1:0.0.1-SNAPSHOT @/workspace/webtest1/pom.xml
...[DEBUG](f) warSourceDirectory =/workspace/webtest1/src/main/webapp
Note that warSourceDirectory points to src (not target), so it runs as an usual dynamic web project, you could change your JSPs, HTMLs and it will visible immediately. That's why the target/tomcat/webapps folder is empty. |
|