在IDEA中动态的指定Maven镜像源

在IDEA中动态的指定Maven镜像源

1 先配置多个镜像源

可以参考:https://my.oschina.net/polly/blog/2120400

2 我的setting.xml如下


<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">

  <localRepository>D:\JavaSoftwareHome\RepositorylocalRepository>

  <mirrors>
    
    <mirror>
      <id>aliyunid>
      <mirrorOf>${aliyun}mirrorOf>
      <name>阿里云公共仓库name>
      <url>https://maven.aliyun.com/repository/publicurl>
    mirror>
    
    <mirror>
      <id>neteaseid>
      <name>网易云仓库name>
      <url>http://mirrors.163.com/maven/repository/maven-public/url>
      <mirrorOf>${netease}mirrorOf>
    mirror>
    
  mirrors>

  <profiles>
    
    <profile>
      <id>jdk-1.8id>
      <activation>
        <jdk>1.8jdk>
      activation>
      <repositories>
        
        <repository>
          <id>springid>
          <url>https://maven.aliyun.com/repository/springurl>
          <releases>
            <enabled>trueenabled>
          releases>
          <snapshots>
            <enabled>trueenabled>
          snapshots>
        repository>
      repositories>
    profile>
    
    <profile>
      <id>adobe-publicid>
      <activation>
        <activeByDefault>trueactiveByDefault>
      activation>
      <properties>
        <releaseRepository-Id>adobe-public-releasesreleaseRepository-Id>
        <releaseRepository-Name>Adobe Public ReleasesreleaseRepository-Name>
        <releaseRepository-URL>https://repo.adobe.com/nexus/content/groups/publicreleaseRepository-URL>
      properties>
      <repositories>
        <repository>
          <id>adobe-public-releasesid>
          <name>Adobe Public Repositoryname>
          <url>https://repo.adobe.com/nexus/content/groups/publicurl>
          <releases>
            <enabled>trueenabled>
            <updatePolicy>neverupdatePolicy>
          releases>
          <snapshots>
            <enabled>falseenabled>
          snapshots>
        repository>
      repositories>
      <pluginRepositories>
        <pluginRepository>
          <id>adobe-public-releasesid>
          <name>Adobe Public Repositoryname>
          <url>https://repo.adobe.com/nexus/content/groups/publicurl>
          <releases>
            <enabled>trueenabled>
            <updatePolicy>neverupdatePolicy>
          releases>
          <snapshots>
            <enabled>falseenabled>
          snapshots>
        pluginRepository>
      pluginRepositories>
    profile>
  profiles>
  
  <activeProfiles>
    <activeProfile>adobe-publicactiveProfile>
    <activeProfile>jdk-1.8activeProfile>
  activeProfiles>
settings>

3 在IDEA中动态指定镜像

(1)在IDEA中:file->settings,找到maven->Importing,修改如下参数:

-D你的<mirrorOf>中的变量名=* # 表示全部代理
-D你的<mirrorOf>中的变量名=central # 表示代理central
# 我的设置
-Daliyun=central # 表示指定阿里云代理central

(2)图片参考:

在IDEA中动态的指定Maven镜像源_第1张图片

你可能感兴趣的:(Maven)