上面方法适合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 nameAttributes: Required Parameters
NameTypeSinceDescriptionfromFileFile-Path to a local file to be uploadedurlString-URL to upload to or download from or list. Must exist and point to a directory.Optional Parameters
NameTypeSinceDescriptionserverIdString-settings.xml's server id for the URL. This is used when wagon needs extra authentication information. Default value is: serverId.skipboolean-When true, skip the execution. Default value is: false.toFileString-Relative path to the URL. When blank, default to fromFile's file name.下面是具体配置 :
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>1.0</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>com.ifeng.tcp.Main</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<id>upload-war</id>
<phase>package</phase>
<goals>
<goal>upload-single</goal>
</goals>
<configuration>
<fromFile>target\${project.artifactId}-${project.version}.${project.packaging}</fromFile>
<url>scp://172.30.22.61/data</url>
<serverId>deploy</serverId>
</configuration>
</execution>
</executions>