gpt4 book ai didi

java - 尝试复制 Artifact 时 Maven 货车错误

转载 作者:行者123 更新时间:2023-12-02 05:57:04 25 4
gpt4 key购买 nike

我正在尝试使用 Maven Wagon 插件将 Artifact 复制到服务器。

我的设置如下:

<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 Artifact ( ${project.build.finalName}.war ),则需要确保 upload-single目标在 package 之后执行阶段(例如 deploy 是合适的)。在您的配置中,您已绑定(bind) 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>

关于java - 尝试复制 Artifact 时 Maven 货车错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29390296/

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