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

     <plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.9</version>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.uri>http://192.168.128.137:8080/manager/text</cargo.remote.uri>
<cargo.remote.username>admin</cargo.remote.username>
<cargo.remote.password>admin</cargo.remote.password>
</properties>
</configuration>
</configuration>
</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再说)
      <role rolename="manager-gui"/>
    <role rolename="manager-script"/>
    <role rolename="manager-jmx"/>
    <role rolename="manager-status"/>
    <role rolename="admin-gui"/>
    <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.).

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

  1. Maven项目远程部署到Tomcat

    目录 Maven项目远程部署到Tomcat 一.Tomcat插件支持的目标 二.系统要求及插件引入 2.1 系统要求 2.2 引入插件 三.远程部署war到tomcat 3.1 添加tomcat管理角 ...

  2. maven eclipse远程部署tomcat

    pom.xml tomcat 配置信息  <properties><project.build.sourceEncoding>utf8</project.build.so ...

  3. Maven: 自动远程部署

    1. 在settings.xml中的Servers节点中增加Server的登录信息: <server> <id>deploy_server_65</id> < ...

  4. 用Maven打包成EAR远程部署JBoss(二)——部署到远程JBoss

    用Maven打包成EAR远程部署JBoss(一)讲了如何使用Maven打包,可是在文章的最后也留下了一个问题,那就是如何将包部署到远程的JBoss中呢?近期在对之前的学习进行总结,发现少了这样一篇重要 ...

  5. 配置Tomcat、maven远程部署调试总结。

    注意:可以搞两个环境,一个本地tomcat 一个服务器上的tomcat ,然后都采用如下配置.这样就可以 在本地调试,调试好后,再发布到服务器端.非常方便.  ==================== ...

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

    使用maven的自动部署功能可以很方便的将maven工程自动打包并且部署到远程tomcat服务器,省去一些繁琐的操作,节省大量时间. 我使用的tomcat版本是8.5,tomcat7和tomcat8都 ...

  7. maven远程部署到tomcat8服务器

    maven远程部署到tomcat8服务器 环境准备 linux服务器一台 服务器安装JDK 服务器安装Tomcat 服务器Tomcat8配置 添加Tomcat权限 配置文件路径: tomcat/con ...

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

    这篇文章.主要是技术上的整理,用来mark一下,用的时候參考. 一.新建项目 新建一个空的Maven Project项目 二.放入依赖 注:ear部署时假设里面有entity,会错误发生.所以不要把e ...

  9. Tomcat热部署:Maven项目一键部署到Tomcat服务器 - 支持多环境

    参考:Eclipse中的Maven项目一键部署到Tomcat服务器 - 支持多环境部署 命令 debug模式设置关联源码 eclipse --> 项目右键 --> Debug As --& ...

随机推荐

  1. maven setting.xml 中文配置详解(全配置)

    春节假期在家养病,乘有时间整理了下之前的知识——知识贵在归纳总结. 参照了官方文档,针对其中的一些未描述详尽的内容翻查了不少资料,补充到了配置文件中,同时再加上一些说明.例子,方便查阅. 内容虽然比较 ...

  2. [原创]java WEB学习笔记15:域对象的属性操作(pageContext,request,session,application) 及 请求的重定向和转发

    本博客为原创:综合 尚硅谷(http://www.atguigu.com)的系统教程(深表感谢)和 网络上的现有资源(博客,文档,图书等),资源的出处我会标明 本博客的目的:①总结自己的学习过程,相当 ...

  3. <Perl算法小菜>排序加速--Schwatzian变换及Guttman-Rosler变换

    原创博客,转载请联系博主! perl里的数据都是以双精度为单元存储的,也就是相当于C/Cpp中的double型,而正则的解析是由perl内置的正则引擎完成的,那么除了重写一个属于自己的排序方法之外,我 ...

  4. POJ 1639 Picnic Planning:最小度限制生成树

    题目链接:http://poj.org/problem?id=1639 题意: 给你一个无向图,n个节点,m条边,每条边有边权. 让你求一棵最小生成树,同时保证1号节点的度数<=k. 题解: 最 ...

  5. ajax实现聊天室功能

    需求如下: 先死后活. 需求分析,分析思路如图所示: 1.创建数据库 create database chat; create table messages( id int unsigned prim ...

  6. 分享知识-快乐自己:Hadoop 常用基础命令

    1): 查询目录下的文件 查询根目录: 查询文件夹下的文件: 2):创建文件夹 3):上传本地文件到HDFS中 上传多个文件: 4):删除文件 5):删除文件夹 6):从HDFS中复制文件到本地 7) ...

  7. elasticsearch的store属性跟_source字段——如果你的文档长度很长,存储了_source,从_source中获取field的代价很大,你可以显式的将某些field的store属性设置为yes,否则设置为no

    转自:http://kangrui.iteye.com/blog/2262860 众所周知_source字段存储的是索引的原始内容,那store属性的设置是为何呢?es为什么要把store的默认取值设 ...

  8. codeforces 710C C. Magic Odd Square(构造)

    题目链接: C. Magic Odd Square Find an n × n matrix with different numbers from 1 to n2, so the sum in ea ...

  9. hdu-5637 Transform(位运算+bfs)

    题目链接: Transform Time Limit: 4000/2000 MS (Java/Others)     Memory Limit: 131072/131072 K (Java/Other ...

  10. 05 - Django应用第二步

    知识点 1) 数据库的配置 涉及到INSTALL_APPS的配置等 初次创建数据的命令 2) 模型的编写 模型的创建方式, 写一个类继承自models.Model 模型的数据类型 外键 自动创建ID列 ...