maven cargo 自动化部署到tomcat

cargo-maven2-plugin的groupId是org.codehaus.cargo,不属于maven官方在groupId,所以在mavne的配置文件settings.xml中找到<pluginGroups>节点,插入<pluginGroup>org.codehaus.cargo</pluginGroup>

  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
	<pluginGroup>org.codehaus.cargo</pluginGroup>
  </pluginGroups>

方便命令行调用。 #部署至本地web容器 Cargo支持两种本地部署的方式,分别为standlone模式和existing模式。在standlone模式中,Cargo会从Web容器在安装目录复制一份配置到用户指定的的目录,然后在此基础上部署上应用,每次重新构建的时候,这个目录都会被清空,所有配置都被重新生成。而在existing模式中,用户需要指定Web容器的目录,Cargo会将Web部署到tomcat目录下。 ##standalone模式 在pom.xml中的配置如下

			<plugin>
				<groupId>org.codehaus.cargo</groupId>
				<artifactId>cargo-maven2-plugin</artifactId>
				<version>1.4.9</version>
				<configuration>
					<container>
						<containerId>tomcat7x</containerId>
						<home>D:\apache-tomcat-7.0.75</home>
					</container>
					<configuration>
						<type>standalone</type>
						<home>${project.build.directory}/tomcat7x</home>
					</configuration>
				</configuration>
			</plugin>

${project.build.directory}/tomcat7x

指的是项目会输出在项目target/tomcat7x下

执行命令: mvn cargo:start ##existing模式

			<plugin>
				<groupId>org.codehaus.cargo</groupId>
				<artifactId>cargo-maven2-plugin</artifactId>
				<version>1.4.9</version>
				<configuration>
					<container>
						<containerId>tomcat7x</containerId>
						<home>D:\apache-tomcat-7.0.75</home>
					</container>
					<configuration>
						<type>existing</type>
						<home>D:\apache-tomcat-7.0.75</home>
					</configuration>
				</configuration>
			</plugin>

#部署至远程服务器 首先需要在tomcat conf/目录下找到tomcat-users.xml,添加如下配置

        <role rolename="manager-gui"/>  
        <role rolename="admin-gui"/>  
        <role rolename="manager-script"/>  
        <user username="tomcat" password="tomcat7" roles="admin-gui, manager-gui,manager-script"/>  

pom.xml配置如下:

	<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.username>tomcat</cargo.remote.username>  
                            <cargo.remote.password>tomcat7</cargo.remote.password>  
                            <cargo.remote.uri>http://localhost:8080/manager/text</cargo.remote.uri>  
                        </properties>  
                    </configuration>  
                </configuration>  
            </plugin>  

远程部署采用的是tomcat的热部署技术,所以要提前启动tomcat

执行命令:mvn cargo:redeploy

转载于:https://my.oschina.net/u/3238650/blog/875216

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值