idea关于pom文件的问题,导入慢,甚至于直接导入失败

idea关于pom文件的问题,导入慢,甚至于直接导入失败

toggle offline mode:切换脱机模式
在这里插入图片描述
当点击这个按钮,就会进入脱机模式
当您切换到脱机模式时,maven必须使用本地的资源,比如依赖(只会本地仓库找,不会网上去下载,如果找不到,则会报错误),
当您需要离线工作或网络连接缓慢时,切换脱机模式非常有用。

进入到换脱机模式,有两种方式:

1)在Maven项目工具窗口的工具栏上,单击按钮。
在这里插入图片描述
2) 在file中 settings 打开“Maven集成”对话框,并在“常规”选项卡中选中“W”选项。
在这里插入图片描述
在这里插入图片描述

修改文件
修改pom文件里的类容
我们可以直接使用idea自带有maven。但是当添加依赖的时候中央仓库位于国外,所以下载速度极慢,这时,我们需要将其更改为国内的镜像,比如阿里云的。
国内出口带宽太小,访问国外网站网速实在是慢得一笔,当遇到大量的机器需要联网更新系统和软件的时候,用镜像站点会大大节省时间提高效率。
导入依赖的时候就会理所应当的很慢,
对应我们个人都比较慢了,更何况对拥有大量服务器资源的互联网企业来说,放在自己环境里的镜像站点对自身大规模的服务器运维也很有帮助。此外像阿里云的镜像站就对阿里云服务器的用户提供了内网访问地址,不占用任何公网流量,对客户也是有好处的。

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">
  <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>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>

    <mirror>
      <id>uk</id>
      <mirrorOf>central</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://uk.maven.org/maven2/</url>
    </mirror>

    <mirror>
      <id>CN</id>
      <name>OSChina Central</name>
      <url>http://maven.oschina.net/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>

    <mirror>
      <id>nexus</id>
      <name>internal nexus repository</name>
      <!-- <url>http://192.168.1.100:8081/nexus/content/groups/public/</url>-->
      <url>http://repo.maven.apache.org/maven2</url>
      <mirrorOf>central</mirrorOf>
    </mirror>

  </mirrors>
</settings>

如图,右键点击pom文件 maven——open ‘setting.xml’(若setting.xml不存在,则create ‘setting.xml’)
在这里插入图片描述
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_49249150/article/details/120938075
今日推荐