maven 远程部署

1、配置tomcat
远程tomcat必须有tomcat自带的manager项目,远程部署就是依靠这个项目来部署的。其次需要配置conf/tomcat-user.xml,配置如下:
<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="dooioo" roles="manager-gui,manager-script,manager-jmx,manager-status"/>
这个主要是给manager项目配置登陆用户名和角色的,比如dooioo登录名此时拥有manager-gui,manager-script,manager-jmx,manager-status多个角色,相应就会有多种权限,最终目的就是让dooioo用户名能有写文件的权限,这个在远程部署时会用到。

2、配置pom.xml
以下是我的配置

            <plugin>

                <groupId>org.codehaus.cargo</groupId>

                <artifactId>cargo-maven2-plugin</artifactId>

                <version>1.4.0</version>

                <configuration>

                    <!-- 容器配置-->

                    <container>

                        <containerId>tomcat7x</containerId>

                        <type>remote</type>  //表示远程部署

                    </container>

                    <!-- Configuration to use with the container -->

                    <configuration>

                        <type>runtime</type>  //表示运行时的tomcat

                        <Properties>

                            <cargo.hostname>192.168.3.100</cargo.hostname>

                            <cargo.remote.uri>http://192.168.3.100/manager/text</cargo.remote.uri>  

                            <cargo.remote.username>admin</cargo.remote.username>  <!- tomcat-user.xml配置->

                            <cargo.remote.password>dooioo</cargo.remote.password>

                        </Properties>

                    </configuration>

                    

                    <!-- Deployables configuration -->

                    <deployables>

                        <deployable>

                            <groupId>项目groupId</groupId>

                            <artifactId>项目artifactId</artifactId>

                            <type>war</type>

                            <properties>

                                <context>/</context>

                            </properties>

                        </deployable>

                    </deployables>

                </configuration>

            </plugin>

3、使用命令:

mvn clean package -Dmaven.test.skip=true cargo:deploy

猜你喜欢

转载自elisonwell.iteye.com/blog/2077879