Maven Cargo 远程部署到tomcat7x

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:

    • If the plugin configuration requires so, installs the container.
    • If the plugin configuration defines a container with a standalone local configuration, it will create the configuration.
    • If the plugin configuration contains one or more deployables, it will deploy these to the container automatically.
    • If the plugin configuration contains no deployables but the project‘s packaging is Java EE (WAR, EAR, etc.), it will deploy the project‘s deployable to to the container automatically.
    • And, of course, start the container.

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:

    • If the plugin configuration requires so, installs the container.
    • If the plugin configuration defines a container with a standalone local configuration, it will create the configuration.
    • If the plugin configuration contains one or more deployables, it will deploy these to the container automatically.
    • If the plugin configuration contains no deployables but the project‘s packaging is Java EE (WAR, EAR, etc.), it will deploy the project‘s deployable to to the container automatically.
    • And, of course, start the container and wait for the user to press CTRL + C to stop.

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.).

时间: 2024-10-06 01:26:32

Maven Cargo 远程部署到tomcat7x的相关文章

bos项目第一天(maven、远程部署、svn、easyui的使用。)

BOS 项目第一天  环境搭建   1.  项目分析 1.1.  产品和项目区别? 产品 先投资 ,做出产品, 再去销售  (QQ. 360 ) 项目 投标 ,分为甲方 (项目应用方)和乙方 (项目开发方), 甲方先给乙方 项目前期款, 交付项目后,收取尾款 . 1.2.  BOS项目规模 项目周期 : 1年多 纯编码时间 : 3个多月 , 项目组开发人员 :20多人 1.3.  系统分类 OA 自动化办公 CRM 客户关系管理 ERP 是针对物资资源管理(物流).人力资源管理(人流).财务资源

Eclipse+Maven远程部署项目到Tomcat中

使用maven的自动部署功能可以很方便的将maven工程自动打包并且部署到远程tomcat服务器,省去一些繁琐的操作,节省大量时间. 我使用的tomcat版本是8.5,tomcat7和tomcat8都可以,安装配置过程比较简单,在此就省略了. 以下是我的安装部署过程: 1.配置tomcat 先是修改tomcat-users.xml文件,该文件在安装目录的conf文件夹下面,我的是在/usr/local/apache-tomcat-8.5.11/conf,在<tomcat-users></

eclipse,myeclipse开发环境下,maven远程部署到tomcat7服务器(图文)

eclipse,myeclipse开发环境下,maven远程部署到tomcat7服务器(图文) 有的人想在eclipse写java web 项目,通过maven也是一种实现的方法,可以实现java web 项目打包成war,发布到tomcat. 在pom.xml文件的build增加下面的代码,相应的地方修改账号和密码,还有发布的名称 , 第一次使用需要下载很多构建. 需耐心等待 ... ... ... <build> <finalName>test_server</final

使用Maven构建和部署J2EE应用程序的EAR文件

这篇文章,主要是技术上的整理,用来mark一下,用的时候参考. 一.新建项目 新建一个空的Maven Project项目 二.放入依赖 注:ear部署时如果里面有entity,会发生错误,所以不要把entity放到依赖项中,部署的时候先部实体,然后再部ear. 将需要打入EAR中的jar.war以dependencies-dependency的形式写到pom.xml文件中,如: 三.配置加载顺序 现在打出来的ear包中的application中只有war的配置信息,而没有jar的配置信息,而我们

jenkins+git+maven搭建自动化部署项目环境

简介    折腾了两个晚上,趁着今晚比较有空,把jenkins+git+maven搭建自动化部署项目环境搭建的过程记录一下,这里我把github作为git的远程仓库(https://github.com/jacky-        lulu/cxf_demo-Maven-Webapp)     系统:centos6.5 maven: Apache Maven 3.3.9 git:git version 2.0.0 1.首先安装git,看以前另外一篇博客 http://www.cnblogs.co

Rsync远程部署

1,使用Rsync实现远程部署 #!/bin/bash cd /var/maven/pdh5/dev/pdh5 git checkout dev git pull origin dev rsync --exclude=*\.log --exclude=\.git* --exclude="log/" -avz /var/maven/pdh5/dev/pdh5/* [email protected]:/var/www/html/h5/pdh5

使用Jenkins远程部署war包到tomcat container

Jenkins首先使用maven将源代码进行编译打包,之后需要将war包传送到tomcat服务器上进行部署. 来看一下Jenkins的基本配置,首先需要安装插件"Deploy to container Plugin": 但是在安装插件时,Jenkins会先ping www.google.com这个域名来保证网络连通性 ,我们需要将其改为www.baidu.com,来使得检查阶段通过: 编辑Jenkins的配置文件default.json: 将connnectionCheckUrl改为h

[原]基于Telnet协议的Jenkins远程部署

最近奉命研究Jenkins的自动远程部署,刚开始进行还算顺利.但是,紧接着问题就来了,我们要部署的目标机器是Telnet协议的.而接触过jenkins的都知道,所有的插件里面只有用于本地部署的和基于SSH协议远程部署的,并没有一个是基于Telnet协议的.那么这该怎么解决呢? 当然,你也可以为你的目标机器安装SSH服务. 我先说说解决的思路,然后再附上具体的步骤和shell脚本. 思路:将jenkins安装在linux系统上 --->  SVN check out 部署的项目  --->  m

Eclipse远程部署

利用 Ant 和 Eclipse 有效地提高部署工作效率 http://www.cnblogs.com/duanxz/p/3422645.html Eclipse使用Ant进行远程部署 http://wenku.baidu.com/link?url=Vu5FYE84PTc60VGsJ2BDUAYmPAPMEzsra3rYZoQN1SOaIYS1aqOybcKXiXYhkmOryDcmM2VFXUd7gc7d_yS_SI3kDFVmRN_P1ekWZEfuEaS eclipse,myeclipse