如果不配置这个,就会导致你的pom.xml文件第一行报错。

尽管你在你的项目中配置了阿里云镜像!

错误内容大多如下。

Failure to find org.springframework.boot:spring-boot-maven-plugin:jar:2.2.5.RELEASE in http://repo.maven.apache.org/maven2 was cached in the local repository, 
 resolution will not be reattempted until the update interval of nexus has elapsed or updates are forced

意思是让你强制更新。

墙内maven深坑之一定要配置全局设置(Global Settings)

然而并没有什么卵用,仍然会报错。这个时候你就应该去检查你的

镜像

直接在pom.xml文件内加入这个即可

    <repositories>
        <repository>
            <id>nexus-aliyun</id>
            <name>Nexus aliyun</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public</url>
        </repository>
    </repositories>

第二步,找到你的maven配置文件,里面的镜像改成如下配置。

  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
    <!-- 阿里云中央仓库 -->
    <mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>central</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>
  </mirrors>

第三步,在你的STS或者是Eclipse中,更改maven的全局配置。

墙内maven深坑之一定要配置全局设置(Global Settings)

最后,在你的项目上右键->maven->update project->记得勾选强制更新。

此时报错就会消失。

需要注意的是,你的User Settings最好也和你的Global Settings保持相同的文件,以免出现意外情况,比如你的全局设置里面有配置阿里云,用户设置却没有。

相关文章:

  • 2021-12-21
  • 2021-08-20
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-06-05
  • 2021-11-20
猜你喜欢
  • 2021-04-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
  • 2021-07-30
相关资源
相似解决方案