最近Eclipse下的很多Maven工程报错,导入其他的Maven工程时也同样报错,报错的日志类似如下,

CoreException: Could not get the value for parameter compilerId for plugin execution default-compile: PluginResolutionException: Plugin org.apache.maven.plugins:maven-compiler-plugin:3.1 or one of its dependencies could not be resolved: The following artifacts could not be resolved: org.apache.maven:maven-core:jar:2.0.9, org.apache.maven:maven-settings:jar:2.0.9, org.apache.maven:maven-plugin-parameter-documenter:jar:2.0.9, org.apache.maven:maven-profile:jar:2.0.9, org.apache.maven:maven-model:jar:2.0.9, org.apache.maven:maven-repository-metadata:jar:2.0.9, org.apache.maven:maven-error-diagnostics:jar:2.0.9, org.apache.maven:maven-project:jar:2.0.9, org.apache.maven:maven-plugin-registry:jar:2.0.9, org.apache.maven:maven-plugin-descriptor:jar:2.0.9, org.apache.maven:maven-artifact-manager:jar:2.0.9, org.apache.maven:maven-monitor:jar:2.0.9, org.apache.maven:maven-toolchain:jar:1.0, org.apache.maven.shared:maven-shared-utils:jar:0.1, com.google.code.findbugs:jsr305:jar:2.0.1, org.apache.maven.shared:maven-shared-incremental:jar:1.1, org.codehaus.plexus:plexus-component-annotations:jar:1.5.5, org.codehaus.plexus:plexus-compiler-api:jar:2.2, org.codehaus.plexus:plexus-compiler-manager:jar:2.2, org.codehaus.plexus:plexus-compiler-javac:jar:2.2, org.codehaus.plexus:plexus-container-default:jar:1.5.5, org.codehaus.plexus:plexus-classworlds:jar:2.2.2, org.apache.xbean:xbean-reflect:jar:3.4, log4j:log4j:jar:1.2.12, commons-logging:commons-logging-api:jar:1.1, com.google.collections:google-collections:jar:1.0: Failure to transfer org.apache.maven:maven-core:jar:2.0.9 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced. Original error: Could not transfer artifact org.apache.maven:maven-core:jar:2.0.9 from/to central (https://repo.maven.apache.org/maven2): The operation was cancelled.

开始认为是org.apache.maven.plugins:maven-compiler-plugin:3.1插件下载失败,检查本地仓库时,发现该插件已下载成功。今天参考 CoreException: Could not get the value for parameter compilerId for plugin execution default-compile 继续向下看日志,关键的错误日志应该是,

Failure to transfer org.apache.maven:maven-core:jar:2.0.9 from https://repo.maven.apache.org/maven2 was cached in the local repository, resolution will not be reattempted until the update interval of central has elapsed or updates are forced.

确认本地仓库中的org.apache.maven:maven-core:jar:2.0.9已下载成功,仍然报错的原因是,

resolution will not be reattempted until the update interval of central has elapsed or updates are forced.

参考 Error in pom.xml Maven build,在Eclipse中使用Alt+F5快捷键,在弹出的Update Maven Project对话框中选择报错的Maven工程,勾选下图中的Force Update of Snapshots/Releases,更新结束后,问题解决。

alt + F5