maven远程部署
2017-06-29 13:04
323 查看
In this tutorial, we will show you how to use Maven-Tomcat
plugin to package and deploy a WAR file to Tomcat, both in Tomcat 6 and 7.
Libraries used :
Maven 3
Tomcat 6.0.37
Tomcat 7.0.53
Tomcat 7
Deploy URL = http://localhost:8080/manager/text
Command =
Tomcat 6
Deploy URL = http://localhost:8080/manager/
Command =
This example shows you how to package and deploy a WAR file on Tomcat 7.
1.1 Tomcat Authentication
Add an user with roles
%TOMCAT7_PATH%/conf/tomcat-users.xml
1.2 Maven Authentication
Add above Tomcat’s user in the Maven setting file, later Maven will use this user to login Tomcat server.
%MAVEN_PATH%/conf/settings.xml
1.3 Tomcat7 Maven Plugin
Declares a Maven Tomcat plugin.
pom.xml
How it works?
During deployment, it tells Maven to deploy the WAR file to Tomcat server via “http://localhost:8080/manager/text” , on path “/mkyongWebApp“, using “TomcatServer” (in settings.xml) username and password for authentication.
1.4 Deploy to Tomcat
Commands to manipulate WAR file on Tomcat.
Example
This example shows you how to package and deploy a WAR file on Tomcat 6. The steps are same with Tomcat 7, just the deploy url and command name are different.
2.1 Tomcat Authentication
%TOMCAT6_PATH%/conf/tomcat-users.xml
2.2 Maven Authentication
%MAVEN_PATH%/conf/settings.xml
2.3 Tomcat6 Maven Plugin
pom.xml
2.4 Deploy to Tomcat
Example
> mvn tomcat6:deploy
... [INFO] Deploying
war to http://localhost:8080/mkyongWebApp
Uploading: http://localhost:8080/manager/deploy?path=%2FmkyongWebApp
Uploaded: http://localhost:8080/manager/deploy?path=%2FmkyongWebApp (13925 KB
at 32995.5 KB/sec)
[INFO]------------------------------------------------------------------------[INFO] BUILD
SUCCESS [INFO]------------------------------------------------------------------------[INFO] Total
time: 22.652 s [INFO] Finished
at: 2014-08-05T12:18:54+08:00 [INFO] Final
Memory: 30M/308M [INFO]------------------------------------------------------------------------
plugin to package and deploy a WAR file to Tomcat, both in Tomcat 6 and 7.
Libraries used :
Maven 3
Tomcat 6.0.37
Tomcat 7.0.53
Tomcat 7
Deploy URL = http://localhost:8080/manager/text
Command =
mvn tomcat7:deploy
Tomcat 6
Deploy URL = http://localhost:8080/manager/
Command =
mvn tomcat6:deploy
1. Tomcat 7 Example
This example shows you how to package and deploy a WAR file on Tomcat 7.1.1 Tomcat Authentication
Add an user with roles
manager-guiand
manager-script.
%TOMCAT7_PATH%/conf/tomcat-users.xml
<?xmlversion='1.0'encoding='utf-8'?><tomcat-users> <rolerolename="manager-gui"/><rolerolename="manager-script"/><userusername="admin"password="password"roles="manager-gui,manager-script"/> </tomcat-users>
1.2 Maven Authentication
Add above Tomcat’s user in the Maven setting file, later Maven will use this user to login Tomcat server.
%MAVEN_PATH%/conf/settings.xml
<?xml version="1.0"encoding="UTF-8"?><settings ...><servers> <server><id>TomcatServer</id><username>admin</username><password>password</password></server> </servers></settings>
1.3 Tomcat7 Maven Plugin
Declares a Maven Tomcat plugin.
pom.xml
<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>TomcatServer</server><path>/mkyongWebApp</path></configuration></plugin>
How it works?
During deployment, it tells Maven to deploy the WAR file to Tomcat server via “http://localhost:8080/manager/text” , on path “/mkyongWebApp“, using “TomcatServer” (in settings.xml) username and password for authentication.
1.4 Deploy to Tomcat
Commands to manipulate WAR file on Tomcat.
mvn tomcat7:deploy mvn tomcat7:undeploy mvn tomcat7:redeploy
Example
> mvn tomcat7:deploy ... [INFO] Deploying war to http://localhost:8080/mkyongWebApp Uploading: http://localhost:8080/manager/text/deploy?path=%2FmkyongWebApp&update=true Uploaded: http://localhost:8080/manager/text/deploy?path=%2FmkyongWebApp&update=true(13925 KB at 35250.9 KB/sec) [INFO] tomcatManager status code:200, ReasonPhrase:OK [INFO] OK - Deployed application at context path /mkyongWebApp [INFO]------------------------------------------------------------------------[INFO] BUILD SUCCESS [INFO]------------------------------------------------------------------------[INFO] Total time: 8.507 s [INFO] Finished at: 2014-08-05T11:35:25+08:00 [INFO] Final Memory: 28M/308M [INFO]------------------------------------------------------------------------
2. Tomcat 6 Example
This example shows you how to package and deploy a WAR file on Tomcat 6. The steps are same with Tomcat 7, just the deploy url and command name are different.2.1 Tomcat Authentication
%TOMCAT6_PATH%/conf/tomcat-users.xml
<?xmlversion='1.0'encoding='utf-8'?><tomcat-users> <rolerolename="manager-gui"/><rolerolename="manager-script"/><userusername="admin"password="password"roles="manager-gui,manager-script"/> </tomcat-users>
2.2 Maven Authentication
%MAVEN_PATH%/conf/settings.xml
<?xml version="1.0"encoding="UTF-8"?><settings ...><servers> <server><id>TomcatServer</id><username>admin</username><password>password</password></server> </servers></settings>
2.3 Tomcat6 Maven Plugin
pom.xml
<plugin><groupId>org.apache.tomcat.maven</groupId><artifactId>tomcat6-maven-plugin</artifactId><version>2.2</version><configuration><url>http://localhost:8080/manager</url><server>TomcatServer</server><path>/mkyongWebApp</path></configuration></plugin>
2.4 Deploy to Tomcat
mvn tomcat6:deploy mvn tomcat6:undeploy mvn tomcat6:redeploy
Example
> mvn tomcat6:deploy
... [INFO] Deploying
war to http://localhost:8080/mkyongWebApp
Uploading: http://localhost:8080/manager/deploy?path=%2FmkyongWebApp
Uploaded: http://localhost:8080/manager/deploy?path=%2FmkyongWebApp (13925 KB
at 32995.5 KB/sec)
[INFO]------------------------------------------------------------------------[INFO] BUILD
SUCCESS [INFO]------------------------------------------------------------------------[INFO] Total
time: 22.652 s [INFO] Finished
at: 2014-08-05T12:18:54+08:00 [INFO] Final
Memory: 30M/308M [INFO]------------------------------------------------------------------------
相关文章推荐
- Nexus搭建Maven私服(五) Maven远程部署web工程
- Maven部署构件至远程仓库
- eclipse+maven远程(自动)部署web项目到tomcat
- Maven远程部署war包到Tomcat
- 用Maven部署war包到远程Tomcat服务器
- Linux Shell脚本之远程自动化部署java maven项目
- maven 部署项目到远程服务器
- 170329、用 Maven 部署 war 包到远程 Tomcat 服务器
- maven使用cargo插件自动化(本地、远程)部署
- maven tomcat8 远程部署(支持tomcat7)
- (转)用 Maven 部署 war 包到远程 Tomcat 服务器
- jenkins部署远程服务器(jenkins+svn+maven)
- 用Maven部署war包到远程Tomcat服务器
- 部署Jar包到远程Maven仓库
- 用Maven打包成EAR远程部署JBoss(二)——部署到远程JBoss
- maven 实现tomcat的远程部署
- Maven部署构件至远程仓库
- maven自动化部署项目到远程服务器(tomcat)
- 配置 WebLogic Maven Plug-In 远程部署weblogic
- maven 插件 一键远程发布部署(jar war)