gpt4 book ai didi

maven-2 - 使用 Maven 通过 SCP 上传文件失败

转载 作者:行者123 更新时间:2023-12-04 01:58:02 26 4
gpt4 key购买 nike

我尝试使用 scp 将 maven 创建的耳朵上传到应用程序服务器。

当我试图跑

mvn wagon:upload-single

但我收到以下错误:
[ERROR] Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-3:upload-single (default-cli) on project de.volkswagen.dps.ear: Unable to create a Wagon instance for null: url can not be null -> [Help 1]org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0-beta-3:upload-single (default-cli) on project de.volkswagen.dps.ear: Unable to create a Wagon instance for null    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:585)    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:324)    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:247)    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:104)    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:427)    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:157)    at org.apache.maven.cli.MavenCli.main(MavenCli.java:121)    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)    at java.lang.reflect.Method.invoke(Method.java:597)    at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)    at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)    at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)    at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)Caused by: org.apache.maven.plugin.MojoExecutionException: Unable to create a Wagon instance for null    at org.codehaus.mojo.wagon.AbstractWagonMojo.createWagon(AbstractWagonMojo.java:83)    at org.codehaus.mojo.wagon.AbstractSingleWagonMojo.execute(AbstractSingleWagonMojo.java:62)    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:105)    at org.apache.maven.lifecycle.DefaultLifecycleExecutor.execute(DefaultLifecycleExecutor.java:577)    ... 14 moreCaused by: java.lang.NullPointerException: url can not be null    at org.apache.maven.wagon.repository.Repository.(Repository.java:88)    at org.codehaus.mojo.wagon.shared.WagonUtils.createWagon(WagonUtils.java:51)    at org.codehaus.mojo.wagon.AbstractWagonMojo.createWagon(AbstractWagonMojo.java:79)    ... 17 more

I tried to add this to the pom, but it doesn't seem to have any effect:

I added the following to the pom.xml:

...
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>1.0-beta-6</version>
</extension>
</extensions>

<plugins>

<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<id>upload-ear</id>
<phase>deploy</phase>
<goals>
<goal>upload</goal>
</goals>
<configuration>
<fromFile>${project.build.directory}/${project.build.finalName}.ear</fromFile>
<url>scp://servername/</url>
<toDir>.</toDir>
</configuration>
</execution>
</executions>
</plugin>
....

任何人都可以解释我如何使这项工作?

最佳答案

您当前的配置遵循 Usage 中给出的示例。页并且是正确的。但是,在本例中,configuration元素在 execution 中声明因此仅适用于 这个特别 execution .

所以当你调用mvn wagon:upload-single在命令行上,configuration没有“使用”,确实没有 url配置的参数。

如果你想从命令行调用插件,可以使用-Durl=foo在命令行传递参数。依此类推或添加“全局”configuration元素:

<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>1.0-beta-6</version>
</extension>
</extensions>

<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<configuration>
<fromFile>${project.build.directory}/${project.build.finalName}.ear</fromFile>
<url>scp://servername/</url>
<toDir>.</toDir>
</configuration>
...
</plugin>
...
</plugins>
...
</build>

关于maven-2 - 使用 Maven 通过 SCP 上传文件失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3300018/

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