我正在尝试使用Maven Wagon插件将工件复制到服务器上。
我设置如下:
<build>
<extensions>
<extension>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>${maven.wagon.version}</version>
</extension>
</extensions>
<plugins>
<plugin>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>${maven.wagon.version}</version>
<!-- <dependencies>
<dependency>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>${maven.wagon.version}</version>
</dependency>
</dependencies> -->
<configuration>
<serverId>appui</serverId>
<fromFile>${project.build.directory}</fromFile>
<includes>${project.build.finalName}.war</includes>
<url>scp://localhost:2221/</url>
<toDir>/opt/jboss/jboss-as-7.1.1.Final/standalone/deployments</toDir>
</configuration>
<executions>
<execution>
<id>upload-war-to-server</id>
<phase>upload</phase>
<goals>
<goal>upload-single</goal>
</goals>
<configuration>
<serverId>appui</serverId>
<fromFile>${project.build.directory}</fromFile>
<includes>${project.build.finalName}.war</includes>
<url>scp://localhost:2221/opt/jboss/jboss-as-7.1.1.Final/standalone/deployments</url>
</configuration>
</execution>
</executions>
</plugin>
然而,当我运行这个程序时,我会得到以下错误:
[ERROR] Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0:upload-single (default-cli) on project app.ui: The parameters 'fromFile', 'url' for goal org.codehaus.mojo:wagon-maven-plugin:1.0:upload-single are missing or invalid -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.codehaus.mojo:wagon-maven-plugin:1.0:upload-single (default-cli) on project app.ui: The parameters 'fromFile', 'url' for goal org.codehaus.mojo:wagon-maven-plugin:1.0:upload-single are missing or invalid
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:221)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:289)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:229)
at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:415)
at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:356)
Caused by: org.apache.maven.plugin.PluginParameterException: The parameters 'fromFile', 'url' for goal org.codehaus.mojo:wagon-maven-plugin:1.0:upload-single are missing or invalid
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:576)
at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:529)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 19 more
[ERROR]
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginParameterException
我已经搜索了github,看看其他人是如何使用Maven Wagon的,我看不出我使用它有什么问题。
您对wagon-maven-plugin
的配置不正确:<fromFile>
需要是对文件的引用,而不是目录。此外,根据文档,没有<includes>
标记。
如果您引用生成的Maven工件(${project.build.finalName}.war
),则需要确保upload-single
目标在package
阶段之后执行(例如,deploy
是合适的)。在您的配置中,您已将upload-single
目标绑定到不存在的阶段"上传"。
这将是最终配置:
<plugin>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-maven-plugin</artifactId>
<version>${maven.wagon.version}</version>
<executions>
<execution>
<id>upload-war-to-server</id>
<phase>deploy</phase>
<goals>
<goal>upload-single</goal>
</goals>
<configuration>
<serverId>appui</serverId>
<fromFile>${project.build.directory}/${project.build.finalName}.war</fromFile>
<url>scp://localhost:2221/opt/jboss/jboss-as-7.1.1.Final/standalone/deployments</url>
</configuration>
</execution>
</executions>
</plugin>