使用Maven自动部署Tomcat 6和Tomcat 7下Web应用

使用Maven自动部署Tomcat 6和Tomcat 7下Web应用

  1. 开启Tomcat远程管理权限

在tomcat的config目录下的tomcat-users.xml文件,

<role rolename="manager-gui"/>

<role rolename="manager-script"/>

<role rolename="manager-jmx"/>

<role rolename="manager-status"/> 

<role rolename="admin-gui"/> 

<role rolename="admin-script"/> 

<user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui,admin-script"/>

 

不多说,此处多给些权限,别小气,否则容易没有权限进行部署(tomcat给的原始配置示例都被<!---->注释掉了)。配置是否成功的验证方法是重启Tomcatà登陆tomcat管理控制台à输入用户名密码后(admin/admin)à部署一个war应用试试,成功则OK,不成功就不要往下走了。

 

  1. 配置tomcat6-maven-plugintomcat7-maven-plugin

工程POM中,配置插件:

Tomcat 6的配置示例如下:

<plugin>

<groupId>org.apache.tomcat.maven</groupId>

<artifactId>tomcat6-maven-plugin</artifactId>

<version>2.2</version>

<configuration>

<url>http://16.158.165.0:8080/manager</url><!-- http://127.0.0.1:8080/manager-->

<username>admin</username>

<password>admin</password>

<path>/BizService</path><!--WEB应用上下文路径-->

</configuration>

</plugin>

 

Tomcat 7的配置示例如下:(注意红色高亮部分差异)

<plugin>

<groupId>org.apache.tomcat.maven</groupId>

<artifactId>tomcat7-maven-plugin</artifactId>

<version>2.2</version>

<configuration>

<url>http://16.158.165.0:8080/manager/text</url>

<username>admin</username>

<password>admin</password>

<path>/BizService</path><!--WEB应用上下文路径-->

</configuration>

</plugin>

 

  1. 部署相关命令

Tomcat 6部署及重新部署命令

mvn tomcat6:deploy

mvn tomcat6:redeploy

 

Tomcat 7部署及重新部署命令

mvn tomcat7:deploy

mvn tomcat7:redeploy

 

  1. 备注

m2eclipse也是如此配置。

<username><password>也可以用<server>方式配置,就是在setting文件中配置用户名密码,POM中只是指定server id,此处不详述。

 

  1. 详细信息(来自官网2.3版本)

Goal

Description

tomcat6:deploy

Deploy a WAR to Tomcat.

tomcat6:deploy-only

Deploy a WAR to Tomcat without forking the package lifecycle.

tomcat6:exploded

Deploy an exploded WAR to Tomcat.

tomcat6:help

Display help information on tomcat6-maven-plugin.
Call mvn tomcat6:help -Ddetail=true -Dgoal=<goal-name> to display parameter details.

tomcat6:info

Lists information about the Tomcat version, OS, and JVM properties.

tomcat6:inplace

Deploy a WAR in-place to Tomcat.

tomcat6:list

Lists all the currently deployed web applications in Tomcat.

tomcat6:redeploy

Redeploy a WAR in Tomcat. (Alias for the deploy goal with its update parameter set to true.)

tomcat6:redeploy-only

Redeploy a WAR in Tomcat without forking the package lifecycle. (Alias for the deploy-only goal with its update parameter set to true.)

tomcat6:reload

Reload a WAR in Tomcat.

tomcat6:resources

Lists JNDI resources in Tomcat.

tomcat6:roles

Lists security roles in Tomcat.

tomcat6:run

Runs the current project as a dynamic web application using an embedded Tomcat server.

tomcat6:run-war

Runs the current project as a packaged web application using an embedded Tomcat server.

tomcat6:run-war-only

Same as run-war goal without forking the package cycle.

tomcat6:sessions

Lists session information for a WAR in Tomcat.

tomcat6:shutdown

Shuts down all possibly started embedded Tomcat servers. This will be automatically done through a shutdown hook or you may call this Mojo to shut them down explictly.

By default the shutdown goal is not bound to any phase. For integration tests you might want to bind it topost-integration-test.

tomcat6:start

Start a WAR in Tomcat.

tomcat6:stop

Stop a WAR in Tomcat.

tomcat6:undeploy

Undeploy a WAR from Tomcat.

使用Maven自动部署Tomcat 6和Tomcat 7下Web应用,布布扣,bubuko.com

使用Maven自动部署Tomcat 6和Tomcat 7下Web应用

上一篇:Jquery简单瀑布流代码示例


下一篇:CSS3圆角气泡框,评论对话框