gpt4 book ai didi

maven - Maven部署到远程主机ssh(scp)而不是存储库

转载 作者:行者123 更新时间:2023-12-02 14:14:23 24 4
gpt4 key购买 nike

我正在尝试将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可以让我不受限制地将文件复制到远程主机,我还缺少什么?

最佳答案

我最终使用了maven-antrun-plugin,但是在该阶段使用了Integration-test。我使用的maven命令是mvn package integration-test。我还使用了trust =“true”属性,因为我无法摆脱jsch异常com.jcraft.jsch.JSchException: UnknownHostKey:。我在这里发布了一个关于此的问题JSch: UnknownHostKey exception even when the hostkey fingerprint is present in the known_hosts file

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<configuration>
<tasks>
<scp todir="vagrant@localhost:~/maven-scp"
port="2200" trust="true" keyfile="C:\keys\openSSH_pair1\open_ssh_private"
failonerror="false" verbose="true" passphrase="pass">
<fileset dir="target">
<include name="xml-to-json-transformer-0.0.1-SNAPSHOT.jar" />
</fileset>
</scp>
</tasks>
</configuration>
<executions>
<execution>
<id>scp</id>
<phase>integration-test</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>com.jcraft</groupId>
<artifactId>jsch</artifactId>
<version>0.1.53</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant-jsch</artifactId>
<version>1.9.6</version>
</dependency>
</dependencies>
</plugin>
</plugins>

关于maven - Maven部署到远程主机ssh(scp)而不是存储库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33749124/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com