码迷,mamicode.com
首页 > 其他好文 > 详细

Maven Cargo 远程部署到tomcat7x

时间:2015-07-10 09:15:42      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:

pom.xml中加入cargo的Plugin声明:

 1     <plugin>
 2         <groupId>org.codehaus.cargo</groupId>
 3         <artifactId>cargo-maven2-plugin</artifactId>
 4         <version>1.4.9</version>
 5         <configuration>
 6             <container>
 7                 <containerId>tomcat7x</containerId>
 8                 <type>remote</type>
 9             </container>
10             <configuration>
11                 <type>runtime</type>
12                 <properties>
13                     <cargo.remote.uri>http://192.168.128.137:8080/manager/text</cargo.remote.uri>
14                     <cargo.remote.username>admin</cargo.remote.username>
15                     <cargo.remote.password>admin</cargo.remote.password>
16                 </properties>
17             </configuration>
18         </configuration>
19     </plugin>

 

With Tomcat 7, the Tomcat manager has multiple aspects to be careful about:

  • Your browser by default accesses the HTML-based manager whereas CARGO needs to use the text-based manager. As a result, if you want to set the RemotePropertySet.URI manually, please make sure you set the URL for the text-based manager, for example http://production27:8080/manager/text
  • The text-based manager requires to be accessed by a user with the manager-script role; and by default no user has that role. As a result, please make sure you modify your tomcat-users.xml file to give that role to a user.
    You can read more in the Tomcat documentation: http://tomcat.apache.org/tomcat-7.0-doc/manager-howto.html

意思是:

  • 属性cargo.remote.uri后面必须是xxx:8080/manager/text格式
  • tomcat7x的权限设置和以前不一样了。要改配置给权限。可以这么改:(不管什么权限,一股脑儿全给admin再说)
    1  <role rolename="manager-gui"/>
    2  <role rolename="manager-script"/>
    3  <role rolename="manager-jmx"/>
    4  <role rolename="manager-status"/>
    5  <role rolename="admin-gui"/>
    6  <user username="admin" password="admin" roles="manager-gui,manager-script,manager-jmx,manager-status,admin-gui"/>

     

另外,无论是博客,还是《Maven实战》都写的是用属性cargo.tomcat.manager.url。可是我看Cargo Tomcat7x文档,甚至Cargo Tomcat6x文档里面都没有提到这个属性。我一开始就用这个属性,结果总是报错,说什么Connection refused。但在这两个文档文档最下面 For remote container o.c.c.c.tomcat.Tomcat7xRemoteContainer 一栏反而有个cargo.remote.uri属性,看名字好像是一个远程uri,我试了试,竟然成功远程部署了。

 所以。。。还是文档比较重要。

https://codehaus-cargo.github.io/cargo/Home.html 里面有好多容器的cargo设置。

最后,你得先保证tomcat7x是运行状态的。用

mvn cargo:redeploy 命令部署就好了。

 cargo的所有goals:(具体运用中自己看吧。。。)

Goals

Description

cargo:start

Start a container. That goal will:

Note: A container that‘s started with cargo:start will automatically shut down as soon as the parent Maven instance quits (i.e., you see a BUILD SUCCESSFUL or BUILD FAILED message). If you want to start a container and perform manual testing, see our next goal cargo:run.

cargo:run

Start a container and wait for the user to press CTRL + C to stop. That goal will:

cargo:stop

Stop a container.

cargo:restart

Stop and start again a container. If the container was not running before calling cargo:restart, it will simply be started.

cargo:configure

Create the configuration for a local container, without starting it. Note that the cargo:start and cargo:run goals will also install the container automatically (but will not call cargo:install).

cargo:package

Package the local container.

cargo:daemon-start

Start a container via the daemon. Read more on: Cargo Daemon

Note: The daemon:start goal is actually equivalent to a restart in CARGO‘s terms; in the case a container with the same cargo.daemon.handleid already exists then it will be stopped first before your container is started. This also implies that in the case the new container fails to start, the old one will not be restarted.

cargo:daemon-stop Stop a container via the daemon. Read more on: Cargo Daemon

cargo:deployer-deploy (aliased to cargo:deploy)

Deploy a deployable to a running container.

Note: The cargo:start and cargo:run do already deploy the deployables specified in the configuration to the container; as a result calling cargo:deploy for a container which has been started by CARGO in the same Maven2/Maven3 project will most likely cause a second deployment of the same deployables (and might even fail).

cargo:deployer-undeploy (aliased to cargo:undeploy)

Undeploy a deployable from a running container.

cargo:deployer-start

Start a deployable already installed in a running container.

cargo:deployer-stop

Stop a deployed deployable without undeploying it.

cargo:deployer-redeploy (aliased to cargo:redeploy)

Undeploy and deploy again a deployable. If the deployable was not deployed before calling cargo:deployer-redeploy (or its alias cargo:redeploy) it will simply be deployed.

cargo:uberwar

Merge several WAR files into one.

cargo:install

Installs a container distribution on the file system. Note that the cargo:start goal will also install the container automatically (but will not call cargo:install).

cargo:help

Get help (list of available goals, available options, etc.).

Maven Cargo 远程部署到tomcat7x

标签:

原文地址:http://www.cnblogs.com/formyjava/p/4626259.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!