还是一如既往的废话不多说,直接开门见山
步骤如下:
1、下载一个绿色版完整的tomcat 包
2、进入tomcat/conf 文件下修改文件 tomcat-users.xml文件
<tomcat-users> <role rolename="admin"/> <role rolename="manager"/> <role rolename="manager-gui"/> <role rolename="manager-script"/> <user username="admin" password="admin" roles="admin,manager,manager-gui,manager-script"/> <tomcat-users/>
修改完成之后,重启tomcat 访问http://192.168.3.141:8050/manager/html 此处是本人自己私服的 IP:PROT
页面如下
3、配置项目pom.xml 文件
<plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>tomcat-maven-plugin</artifactId> <version>1.1-SNAPSHOT</version> <configuration> <url>http://192.168.3.141:8050/manager/text</url> <server>tomcat</server> <path>/</path> </configuration> </plugin>
注:此处的url 注意是xxx/manager/text 并非是 xxx/manager/html 原因是我用的tomcat 是tomcat7 的版本
4、配置maven 的setting.xml 文件
<server> <id>tomcat</id> <username>admin</username> <password>admin</password> </server>
5、ok 到此一切配置工作配置完毕
开始运行 mvn tomcat:redeploy
Jerry:prjGuSi Jerry$ mvn tomcat:redeploy [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building prjGuSi Maven Webapp 5.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] >>> tomcat-maven-plugin:1.1-SNAPSHOT:redeploy (default-cli) @ prjGuSi >>> [WARNING] The artifact freemarker:freemarker:jar:2.3.9 has been relocated to org.freemarker:freemarker:jar:2.3.9 [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ prjGuSi --- [INFO] Using ‘UTF-8‘ encoding to copy filtered resources. [INFO] Copying 15 resources [INFO] [INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ prjGuSi --- [INFO] Changes detected - recompiling the module! [INFO] Compiling 64 source files to /Users/Jerry/work/IdeaProjects/branch/prjGuSi/target/classes [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ prjGuSi --- [INFO] Using ‘UTF-8‘ encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /Users/Jerry/work/IdeaProjects/branch/prjGuSi/src/test/resources [INFO] [INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ prjGuSi --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.6:test (default-test) @ prjGuSi --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-war-plugin:2.2:war (default-war) @ prjGuSi --- [INFO] Packaging webapp [INFO] Assembling webapp [prjGuSi] in [/Users/Jerry/work/IdeaProjects/branch/prjGuSi/target/ROOT] [INFO] Processing war project [INFO] Copying webapp resources [/Users/Jerry/work/IdeaProjects/branch/prjGuSi/src/main/webapp] [INFO] Webapp assembled in [350 msecs] [INFO] Building war: /Users/Jerry/work/IdeaProjects/branch/prjGuSi/target/ROOT.war [INFO] WEB-INF/web.xml already added, skipping [INFO] [INFO] <<< tomcat-maven-plugin:1.1-SNAPSHOT:redeploy (default-cli) @ prjGuSi <<< [INFO] [INFO] --- tomcat-maven-plugin:1.1-SNAPSHOT:redeploy (default-cli) @ prjGuSi --- [INFO] Deploying war to http://192.168.3.141:8050/ [INFO] OK - Deployed application at context path / [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 21.527s [INFO] Finished at: Sun Jul 27 16:32:52 CST 2014 [INFO] Final Memory: 22M/439M [INFO] ------------------------------------------------------------------------
ok,可以看出部署成功…… 针对此次试水,遇到的问题分析请移步 -》》》》http://my.oschina.net/jerryhu/blog/295279
采用maven 对tomcat 进行自动部署
时间: 2024-10-17 13:00:32