之前在项目中不多使用Maven,最近本身学习了一下maven,真的是很是强大的项目构建工具,对于依赖包的定义及版本,以及依赖包的集中管理(中央仓库)都让人惊喜(原谅个人大惊小怪,虽然Maven出来好久了,但小弟刚接触),但发现开发Web项目时,须要手动部署到Web服务器(Tomcat7),若是能自动部署到Web服务器,而不用每次手动把target下编译好的war包拷贝到Tomcat下就更好了。 apache
下面是具体的使用方法: tomcat
<role rolename="admin-gui"/> <role rolename="admin-script"/> <role rolename="manager-gui"/> <role rolename="manager-script"/> <role rolename="manager-jmx"/> <role rolename="manager-status"/> <user username="admin" password="password" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-script,admin-gui"/>
<server> <id>tomcat7</id> <username>admin</username> <password>password</password> </server>
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.1</version> <configuration> <!-- 注意此处的url --> <url>http://localhost:8080/manager/text</url> <server>tomcat7</server> <!-- 此处的名字必须和setting.xml中配置的ID一致--> <path>/mavenProject</path> <!-- 此处的名字是项目发布的工程名--> </configuration> </plugin>
最后,只须要mvn tomcat7:deploy就能够了(必须事先启动tomcat服务器) 服务器