1.安装maven
参见 eclipse maven plugin 插件 安装 和 配置
2.安装tomcat7
下载地址 http://apache.fayea.com/apache-mirror/tomcat/tomcat-7/v7.0.50/bin/apache-tomcat-7.0.50.zip
3.修改tomcat-users.xml,增加默认用户权限
<role rolename="manager"/> <role rolename="admin"/> <role rolename="manager-gui"/> <user username = "admin" password = "password" roles = "admin,manager,manager-gui,manager-script,manager-jmx,manager-status" />
4.修改maven配置文件,添加server节点
<server> <id>tomcat</id> <username>admin</username> <password>password</password> </server>
5.修改项目pom.xml,在build节点下增加plugin节点
<build> <pluginManagement> <plugins> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <url>http://localhost:8080/manager/text</url> <server>tomcat</server> <username>admin</username> <password>password</password> </configuration> </plugin> </plugins> </pluginManagement> </build>
6.配置发布选项,点击"Browse Workspace..."选择项目目录,Goals设置发布命令:"package tomcat7:redeploy",最后点击"Run",即开始自动发布