无法从插件 'org.codehaus.mojo:build-helper-maven-plugin:1.9' 加载 mojo 'add-source'(或其所需组件之一)

Unable to load the mojo 'add-source' (or one of its required components) from the plugin 'org.codehaus.mojo:build-helper-maven-plugin:1.9'

我正在使用以下 Maven 插件:

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>build-helper-maven-plugin</artifactId>
            <version>1.9</version>
            <executions>
                <execution>
                    <id>add-source</id>
                    <phase>generate-sources</phase>
                    <goals>
                        <goal>add-source</goal>
                    </goals>
                    <configuration>
                        <sources>
                            <source>${basedir}/target/generated/src/main/java</source>
                        </sources>
                    </configuration>
                </execution>
            </executions>
        </plugin>

Eclipse 一直显示以下错误:

Execution add-source of goal org.codehaus.mojo:build-helper-maven-plugin:1.9:add-source failed: Unable to load the mojo 'add-source' (or one of its required components) from the plugin 'org.codehaus.mojo:build-helper-maven-plugin:1.9' (org.codehaus.mojo:build-helper-maven-plugin:1.9:add-source:add-source:generate-sources) org.apache.maven.plugin.PluginExecutionException: Execution add-source of goal org.codehaus.mojo:build-helper-maven-plugin:1.9:add-source failed: Unable to load the mojo 'add-source' (or one of its required components) from the plugin 'org.codehaus.mojo:build-helper-maven-plugin:1.9'

我做错了什么?

当项目由于某种原因失去 Maven 性质时,就会发生这种情况。

简单右击Eclipse项目然后select

"Configure - Convert to Maven Project".