修复 Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:build-helper-maven-plu...

在maven项目中使用add-source时,pom.xml报如下错误:

Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:build-helper-maven-plugin:1.8:add-source (execution: add-source, phase: generate-sources)

加入的代码如下:

            <plugin>
                <groupId>org.codehaus.mojogroupId>
                <artifactId>build-helper-maven-pluginartifactId>
                <version>1.8version>
                <executions>
                    <execution>
                        <id>add-sourceid>
                        <phase>generate-sourcesphase>
                        <goals>
                            <goal>add-sourcegoal>
                        goals>
                        <configuration>
                            <sources>
                                <source>${basedir}/src/main/entitysource>
                                <source>${basedir}/src/main/modulessource>
                            sources>
                        configuration>
                    execution>
                executions>
            plugin>

原因是eclipse的m2e插件还没支持到execution,解决办法如下

在pom.xml文件中,后加入如下代码:

<pluginManagement>
    <plugins>
        
        <plugin>
            <groupId>org.eclipse.m2egroupId>
            <artifactId>lifecycle-mappingartifactId>
            <version>1.0.0version>
            <configuration>
                <lifecycleMappingMetadata>
                    <pluginExecutions>
                        <pluginExecution>
                            <pluginExecutionFilter>
                                <groupId>
                                    org.codehaus.mojo
                                groupId>
                                <artifactId>
                                    build-helper-maven-plugin
                                artifactId>
                                <versionRange>
                                    [1.8,)
                                versionRange>
                                <goals>
                                    <goal>add-sourcegoal>
                                goals>
                            pluginExecutionFilter>
                            <action>
                                <ignore>ignore>
                            action>
                        pluginExecution>
                    pluginExecutions>
                lifecycleMappingMetadata>
            configuration>
        plugin>
    plugins>
pluginManagement>

然后maven -> Update Project 即可

转载于:https://www.cnblogs.com/guyezhai/p/5629822.html

你可能感兴趣的:(修复 Plugin execution not covered by lifecycle configuration: org.codehaus.mojo:build-helper-maven-plu...)