maven利用cargo插件本地远程部署

用了一些部署工具:发现Cargo工具部署比较方便,特此推荐一下~

Cargo分为standalone和existing模式

standalone模式:会从Web容器目录复制一份配置到用户指定的目录,然后在此基础上部署应用,每次重新构建,这个目录会被清空,所有配置重新生成



existing:用户需要指定现有的Web容器配置目录, 然后Cargo会直接使用这些配置并将应用部署到对应的位置。



cargo不属于官方的。。  调用时候,用户需要添加到settings.xml中   。 不过用myeclipse 插件用全局的时候不需要配置也可以用命令直接运行



$ mvn  cargo:start





01.<plugin>  
02.                <groupId>org.codehaus.cargo</groupId>  
03.                <artifactId>cargo-maven2-plugin</artifactId>  
04.                <version>1.1.3</version>  
05.                <configuration>  
06.                    <container>  
07.                        <containerId>tomcat7x</containerId>  
08.                        <home>E:\tomcat\apache-tomcat-7.0.26</home>  
09.                    </container>  
10.                    <configuration>  
11.                        <type>existing</type>  
12.                        <home>E:\tomcat\apache-tomcat-7.0.26</home>  
13.                        <!--   
14.                            <type>standalone</type>  
15.                            <home>${project.build.directory}/tomcat7x</home>  
16.                         -->  
17.                    </configuration>  
18.                </configuration>  
19.            </plugin>  
 


<home> 就是需要部署的位置





当然Cargo也支持远程Web容器的部署



大体上配置差不多



01.<plugin>  
02.                <groupId>org.codehaus.cargo</groupId>  
03.                <artifactId>cargo-maven2-plugin</artifactId>  
04.                <version>1.1.3</version>  
05.                <configuration>  
06.                    <container>  
07.                        <containerId>tomcat7x</containerId>  
08.                        <type>remote</type>  
09.                    </container>  
10.                    <configuration>  
11.                        <type>runtime</type>  
12.                        <properties>  
13.                            <cargo.remote.username>tomcat</cargo.remote.username>  
14.                            <cargo.remote.password>tomcat</cargo.remote.password>  
15.                            <cargo.remote.manager.url>http://localhost:8080/manager</cargo.remote.manager.url>  
16.                        </properties>  
17.                    </configuration>  
18.                </configuration>  
19.            </plugin>  
 


必须显示的指定type 否则cargo会默认的认为你是用installed(默认值)



命令:  $mvn cargo:redeploy



远程部署时候,如果容器已经部署了当前应用,会卸载然后重新部署。



最后部署到tomcat中的war文件名为 你自己的maven项目的 artifactId + version 

猜你喜欢

转载自bioubiou.iteye.com/blog/1873794
今日推荐