-1

我正在尝试清理、构建和打包我的项目,但我不断收到此错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.6.1:clean (auto-clean) on project Presentation: Unable to parse configuration of mojo org.apache.maven.plugins:maven-clean-plugin:2.6.1:clean for parameter retryOnError: Cannot find 'retryOnError' in class org.apache.maven.plugin.clean.CleanMojo -> [Help 1]
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-clean-plugin:2.6.1:clean (auto-clean) on project Presentation: Unable to parse configuration of mojo org.apache.maven.plugins:maven-clean-plugin:2.6.1:clean for parameter retryOnError: Cannot find 'retryOnError' in class org.apache.maven.plugin.clean.CleanMojo
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:220)
    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:108)
    at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:76)
    at org.apache.maven.lifecycle.internal.builder.singlethreaded.SingleThreadedBuilder.build(SingleThreadedBuilder.java:51)
    at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:116)
    at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:361)
    at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:155)
    at org.apache.maven.cli.MavenCli.execute(MavenCli.java:584)
    at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:213)
    at org.apache.maven.cli.MavenCli.main(MavenCli.java:157)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:483)
    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.PluginConfigurationException: Unable to parse configuration of mojo org.apache.maven.plugins:maven-clean-plugin:2.6.1:clean for parameter retryOnError: Cannot find 'retryOnError' in class org.apache.maven.plugin.clean.CleanMojo
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:605)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:537)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:120)
    at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208)
... 19 more
Caused by: org.codehaus.plexus.component.configurator.ComponentConfigurationException: Cannot find 'retryOnError' in class org.apache.maven.plugin.clean.CleanMojo
    at org.eclipse.sisu.plexus.CompositeBeanHelper.setProperty(CompositeBeanHelper.java:252)
    at org.codehaus.plexus.component.configurator.converters.composite.ObjectWithFieldsConverter.processConfiguration(ObjectWithFieldsConverter.java:101)
    at org.codehaus.plexus.component.configurator.BasicComponentConfigurator.configureComponent(BasicComponentConfigurator.java:32)
    at org.apache.maven.plugin.internal.DefaultMavenPluginManager.populatePluginFields(DefaultMavenPluginManager.java:575)
... 22 more

一段时间以来,我一直在努力为自己弄清楚这一点。我将项目设置为自动清理,这正是 Apache 在 pom 文件中指示这样做的方式,但我也会将其包括在内。

<project>
    <build>
        ...
        <plugin>
            <artifactId>maven-clean-plugin</artifactId>
            <version>2.6.1</version>
            <configuration>
                <failOnError>false</failOnError>
            </configuration>
            <executions>
                <execution>
                    <id>auto-clean</id>
                    <phase>initialize</phase>
                    <goals>
                        <goal>clean</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        ...
    </build>
<project>

我在这里迷路了。显然,它与“retryOnError”有关,但这不是我自己添加的。我在哪里可以找到那个?

另外,如果有帮助,我正在使用 Maven 3.2.5。

4

2 回答 2

1

看起来您明确配置的 clean 插件的版本与 maven 随附的版本不同(或默认属性中的类似不匹配)

正如上面的评论所暗示的,我将删除整个部分:

<plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <version>2.6.1</version>
    <configuration>
        <failOnError>false</failOnError>
    </configuration>
    <executions>
        <execution>
            <id>auto-clean</id>
            <phase>initialize</phase>
            <goals>
                <goal>clean</goal>
            </goals>
        </execution>
    </executions>
</plugin>

然后运行 ​​mvn clean / mvn clean 包。

如果您设置使用插件,您还应该尝试在配置中手动设置属性,如下所示:

<plugin>
    <artifactId>maven-clean-plugin</artifactId>
    <version>2.6.1</version>
    <configuration>
        <failOnError>false</failOnError>
        <retryOnError>true</retryOnError>
    </configuration>
    <executions>
        <execution>
            <id>auto-clean</id>
            <phase>initialize</phase>
            <goals>
                <goal>clean</goal>
            </goals>
        </execution>
    </executions>
</plugin>
于 2015-05-01T20:42:08.807 回答
1

@ɐuıɥɔɐɯ 是对的。

我还会尝试删除 pom.xml 中的自动清理插件配置,因为找出它导致问题的原因可能比它值得做的工作更多。现在,我只需在项目的根文件夹中运行以下命令:

mvn clean package

这应该运行您在 pom.xml 中列出的目标,并清理您的“目标”子目录,将其替换为最新的代码。

有关更多信息,请参阅http://www.mkyong.com/maven/how-to-clean-project-with-maven/

于 2015-05-01T20:40:35.757 回答