我正在尝试将 maven 构建的 jar 复制到远程主机中的目录,而不是存储库。我在这里尝试了 user1050755 的答案Using Maven for deployment,它使用了 maven-antrun-plugin 并且我也尝试了 wagon-ssh 插件。以下是我的 pom.xml 中希望相关的摘录
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>2.9</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<id>xd</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<fromDir>target</fromDir>
<includes>xml-to-json-transformer-0.0.1-SNAPSHOT.jar</includes>
<excludes/>
<url>scp://spade.innoimm.local</url>
<toDir>/opt/xd/custom-modules/processor</toDir>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>scp</id>
<phase>deploy</phase>
<configuration>
<tasks>
<scp todir="root@spade:/opt/xd/custom-modules/processor"
sftp="true"
keyfile="C:\MerucurioVagrant\repo\mercurio-vagrant\insecure_private_key.ppk"
failonerror="false"
verbose="true"
passphrase="nopass"
>
<fileset dir="target">
<include
name="xml-to-json-transformer-0.0.1-SNAPSHOT.jar"/>
</fileset>
</scp>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.9.4</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
对于这两个插件,我得到相同的错误
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy (default-deploy) on project xml-to-json-transformer: Deployment failed: repository element was not specified in the POM inside distributionManagement element or in -DaltDeploymentRepository=id::layout::url parameter -> [Help 1]
但是我不想部署到存储库,我认为 antrun-plugin 只会让我将文件复制到没有限制的远程主机,我错过了什么?