maven实现项目远程部署到tomcat(热部署)

http://shellblog.sinaapp.com/?p=66


1.配置远程的tomcat7,修改conf下的 tomcat-users.xml文件,如下:

1
2
3
4
"manager-gui" />
     "manager-script" />
     "tomcat" password= "tomcat" 
             roles= "manager-gui,manager-script" />

2.在POM中加入部署插件,如下:

1
2
3
4
5
6
7
8
         org.codehaus.mojo
         tomcat-maven-plugin
        
             http: //192.168.5.231:8585/manager/html
             test
        
    

 
3.修改maven配置文件:settings.xml,在其中加入test的配置:

1
2
3
4
5
        test
        tomcat
        tomcat
   

4.配置完成,执行命令:

1
mvn tomcat:redeploy

 
上述方式为tomcat热部署,不需要重启服务器。



上面方法适合web 项目并且是热部署,下面是一种自动打包并上传的办法

主要插件:

wagon:upload-single

Full name:

org.codehaus.mojo:wagon-maven-plugin:1.0-beta-4:upload-single

Description:

Upload a single file with option to change name

Attributes:

Required Parameters

Name Type Since Description
fromFile File - Path to a local file to be uploaded
url String - URL to upload to or download from or list. Must exist and point to a directory.

Optional Parameters

Name Type Since Description
serverId String - settings.xml's server id for the URL. This is used when wagon needs extra authentication information.
Default value isserverId.
skip boolean - When true, skip the execution.
Default value isfalse.
toFile String - Relative path to the URL. When blank, default to fromFile's file name.
下面是具体配置 :



org.apache.maven.wagon
wagon-ssh
1.0




org.apache.maven.plugins
maven-shade-plugin
2.1


package

shade




implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
com.ifeng.tcp.Main







org.codehaus.mojo
wagon-maven-plugin
1.0-beta-3


upload-war
package

upload-single


target\${project.artifactId}-${project.version}.${project.packaging}
scp://172.30.22.61/data
deploy









你可能感兴趣的:(maven)