Eclipse下运行Maven项目提示缺少maven-resources-plugin:2.4.3

将一个手动创建的Maven项目(命令行下可正常运行)导入到Eclipse中,运行时提示这样的错误信息:
[ERROR] Plugin org.apache.maven.plugins:maven-resources-plugin:2.4.3 or one of its dependencies could  not be resolved: 
Failed to collect dependencies for org.apache.maven.plugins:maven-resources-plugin:jar:2.4.3

解决步骤:

1、在项目的 pom.xml 文件中新增一个依赖,代码如下:

    <dependency>
        <groupId>org.apache.maven.plugins</groupId>
        <artifactId>maven-resources-plugin</artifactId>
        <version>2.4.3</version>
    </dependency>

2、在命令行下运行 mvn install

    如果执行正确应该会在{user.home}\.m2\repository\org\apache\maven\plugins\maven- resources-plugin\2.4.3目录下下看到maven-resources-plugin-2.4.3.jar文件

    注意:

        a、运行 mvn install 时要在 该项目的主文件夹下运行,即和 pom.xml 同目录

        b、运行下来也许不会有 2.4.3 这个目录,但一定会有 maven-resources-plugin-2.4.3.jar 文件。因为笔者的本地仓库下,maven-resources-plugin有多个不同版本。

3、刷新工程(右键工程选择刷新项)

4、刷新maven配置

    右键工程节点,选择 Maven4MyEclipse - Update Project Configuration

   

猜你喜欢

转载自blog.csdn.net/weixin_41585557/article/details/81393733