通过maven的tomcat插件来启动tomcat7(默认是tomcat6)

原文: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.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值