我尝试使用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 more Caused 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
我试图将它添加到pom中,但似乎没有任何效果:
我在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>
....
有人可以解释一下我是如何做到这一点的吗?
答案 0 :(得分:15)
您当前的配置遵循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>
答案 1 :(得分:0)
您可以使用 pom.xml
上的配置运行以下命令来运行插件:
mvn org.codehaus.mojo:wagon-maven-plugin:upload@upload-ear