Idea配置Maven阿里云镜像加速的实现

如果没有安装过maven,是用的idea自带的maven,那就是idea的安装目录下 /plugins/maven/lib/maven3这个目录。

然后在conf下打开settings.xml,加入如下代码:

  <mirrors>
	<mirror>
		<id>aliyunmaven</id>
		<mirrorOf>*</mirrorOf>
		<name>阿里云公共仓库</name>
		<url>https://maven.aliyun.com/repository/public</url>
	</mirror>
  </mirrors>

如果默认用1.8jdk,可以添加:

<profile>
	<id>jdk-1.8</id>
	<activation>
		<activeByDefault>true</activeByDefault>
		<jdk>1.8</jdk>
	</activation>
	<properties>
		<maven.compiler.source>1.8</maven.compiler.source>
		<maven.compiler.target>1.8</maven.compiler.target>
		<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
	</properties>
</profile>

全部代码如下:

<?xml version="1.0" encoding="UTF-8"?>

<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->

<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.conf}/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<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
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->

  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->

  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   |
   | Default: false
  <offline>false</offline>
  -->

  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>

  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>

  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->

    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
  </servers>

  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>
	<mirror>
		<id>aliyunmaven</id>
		<mirrorOf>*</mirrorOf>
		<name>阿里云公共仓库</name>
		<url>https://maven.aliyun.com/repository/public</url>
	</mirror>
    <!-- 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>
     -->
  </mirrors>

  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   |
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is
   | dereferenced during the build process to configure the cactus plugin.
   |
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a system property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   |
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
   |
   |-->
  <profiles>
    <!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>
      <id>jdk-1.4</id>

      <activation>
        <jdk>1.4</jdk>
      </activation>

      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    -->
	<profile>
		<id>jdk-1.8</id>
		<activation>
			<activeByDefault>true</activeByDefault>
			<jdk>1.8</jdk>
		</activation>
		<properties>
			<maven.compiler.source>1.8</maven.compiler.source>
			<maven.compiler.target>1.8</maven.compiler.target>
			<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
		</properties>
	</profile>

    <!--
     | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
     | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
     | might hypothetically look like:
     |
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     |
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
     |
    <profile>
      <id>env-dev</id>

      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>

      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
    -->
  </profiles>

  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
</settings>

到此这篇关于Idea配置Maven阿里云镜像加速的实现的文章就介绍到这了,更多相关Idea Maven阿里云镜像加速内容请搜索我们以前的文章或继续浏览下面的相关文章希望大家以后多多支持我们!

(0)

相关推荐

  • 浅谈Maven的安装及修改为阿里云下载依赖

    使用JAVA工程管理越来越多的jar包,担心导错了,多导了,漏导了怎么办? 换一个IDE项目后项目会不会出一堆BUG,看的头皮发麻? 自己写的代码放在别人的机器上运行会不会出问题? Maven的强大毋庸置疑,当使用Maven后以上这些都不是问题,但是配置maven是一件耐心的事情,基本步骤总结如下: 一.下载 http://maven.apache.org/download.cgi 也可以直接在eclipse工具中下载,点击eclipse菜单栏Help->Eclipse Marketplace搜

  • 浅谈Maven镜像更换为阿里云中央仓库(精)

    前言 每次update Maven Project 的时候,看着进度条寸步难行,心里憋得十分难受,明显阻碍我学习的热情. maven仓库默认在国外,使用难免很慢,尤其是下载依赖的时候,换为国内镜像,让你感受飞一般的感觉.国内支持maven镜像的有阿里云,开源中国等,这里换为阿里云的. 更换 修改maven配置文件settings.xml (当然也可以在用户home目录.m2下面添加一个settings.xml文件) $ cd $M2_HOME/conf/ $ sudo vim settings.

  • 详解阿里云maven镜像库配置(gradle,maven)

    经常使用maven远程仓库里jar包的同学,最头疼的事情莫过于加了jar包依赖配置之后,需要漫长的下jar包的过程,因为maven仓库网站是国外网站,速度非常的慢.在国内下好jar包放到本地再加载又过于麻烦. 以前有个oschina的国内maven镜像仓库地址,现在应该是弃用了(害得我也等了半天)现在国内的话主要使用阿里云的maven镜像仓库,速度很快~~~ gradle配置:将原来的mavenCentral()直接替换掉或者放到这个的前面(默认是从上往下寻找,所以要放到mavenCentral

  • maven下载jar包改用阿里云maven库的方法

    本文介绍了maven下载jar包改用阿里云maven库的方法,分享给大家,具体如下: 修改maven安装路径中conf文件夹下的setting.xml文件 <mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>http://maven.aliyun.com/nexus/content/groups/public/</url> &l

  • 详解Maven settings.xml配置(指定本地仓库、阿里云镜像设置)

    一.settings.xml文件会在两个目录下存在: 1.Maven安装目录(全局):%MAVEN_HOME%\conf\settings.xml 2.用户安装目录(用户):${user.home}\.m2\settings.xml 第一个是全局配置,第二个是用户配置.当两者都存在,它们的内容将被合并,特定于用户的settings.xml文件占主导地位. 如果从头开始创建用户特定的配置,可以将全局的settings.xml复制到${user.home}\.m2目录下. 我的Maven安装目录:(

  • 更改Maven软件源为阿里云源的方法详解

    找到maven文件夹 –>conf–>setting.xml 右键编辑,然后找到mirror 更改为如下: <mirrors> <mirror> <id>alimaven</id> <name>aliyun maven</name> <url>https://maven.aliyun.com/repository/central</url> <mirrorOf>central</m

  • maven+阿里云创建国内镜像的中央仓库(亲测可用)

    众所周知,在墙内开发很头疼的一件事就是Maven仓库的连接速度太慢.虽然对于很多互联网企业和大中型软件公司,建个镜像是分分钟的事.但对于个人开发者和小公司来说,确实是个问题.之前有一阵子开源中国有提供maven仓库镜像,但目前已经无法使用了. 下面是大师兄测试记录 修改maven根目录下的conf文件夹中的setting.xml文件,如果你跟我一样修改了默认仓库的存储位置,即.m2文件夹下没有本地仓库,但是有个setting.xml文件,那就修改这个文件就可以啦. 具体内容和示意图如下: <mi

  • Idea配置Maven阿里云镜像加速的实现

    如果没有安装过maven,是用的idea自带的maven,那就是idea的安装目录下 /plugins/maven/lib/maven3这个目录. 然后在conf下打开settings.xml,加入如下代码: <mirrors> <mirror> <id>aliyunmaven</id> <mirrorOf>*</mirrorOf> <name>阿里云公共仓库</name> <url>https:/

  • Docker配置阿里云镜像加速pull的实现

    今天使用docker拉取镜像,那速度简直不能看,而且等着等着到最后还出现了 read tcp 192.168.31.60:55550->104.18.123.25:443: read: connection reset by peer 传输异常 然后看见网上说可以配置阿里云提供的镜像加速 具体方式 进入阿里云的容器镜像服务 快速链接: 容器镜像服务 复制加速器的地址 在/etc/docker目录下找到在daemon.json文件(没有就新建),将下面内容写入 { "registry-mir

  • 安装Docker配置阿里云镜像加速(图文教程)

    目录 docker安装环境准备: 环境查看: 安装Docker: 一.下载需要的安装包: 二.设置Docker镜像仓库: 三.安装Docker相关内容 启动Docker: 卸载Docker: 阿里云镜像加速: docker安装环境准备: 配置一台可以上网的虚拟机: 需要一台可以使用的虚拟机,这里使用的是Linux的centos7系统配置docker环境. 这样配置的虚拟机就可以流畅运行docker的学习环境了. 环境查看: #查看系统内核是否是3.0以上的 uname -r #查看系统版本:ca

  • docker配置修改阿里云镜像仓库的实现

      docker本身的仓库非常慢,但是国内有阿里云的镜像仓库非常快.当然也可以用其他地方的镜像仓库,有很多的,配置阿里云的方式如下: 配置步骤 1.申请阿里云账号   首先百度搜索阿里云,进入官网,注册阿里云账号,可以用淘宝账号登录. 2.找到阿里云加速器地址   注册之后,登录,先点击控制台.如下图:   然后按照下图操作,找到加速器.   但是首次点击,会提示你开通这种服务,你只要输入上密码即可,然后:   如上图框选位置,将它复制下来即可. 3.配置阿里云镜像仓库   然后在我们的linu

  • 解读maven配置阿里云镜像问题

    目录 maven配置阿里云镜像 maven配置阿里云镜像仓库不生效 问题 解决方法 原因 maven配置阿里云镜像 打开maven配置文件,找到标签,添加如下: <mirrors>   <mirror>      <id>alimaven</id>      <name>aliyun maven</name>      <url>http://maven.aliyun.com/nexus/content/groups/pu

  • Docker安装及阿里云镜像加速器的配置方法

    Docker安装 Windows系统安装就不用说了,因为Docker是开源的,所以,直接去官网:https://www.docker.com/下载安装包安装就行了 其实,Linux系统安装也很简单,照着官网给的命令一通写下来,就安装成功了,然后启动服务,就可以使用了,比如:我的系统是CentOS7,它的安装如下: 首先来到CentOS安装Docker的官网说明文档:https://docs.docker.com/engine/install/centos/ 我原来没安装过其他版本的Docker,

  • docker配置阿里云镜像仓库的实现

    目录 1.1 登录阿里云找到容器镜像服务 1.2 在服务器上配置仓库 1.1 登录阿里云找到容器镜像服务 1.2 在服务器上配置仓库 直接复制官网上的指令即可 # 创建文件夹 sudo mkdir -p /etc/docker # 添加配置文件 sudo tee /etc/docker/daemon.json <<-'EOF' { "registry-mirrors": ["https://自己的地址.mirror.aliyuncs.com"] } EO

  • Android Studio Gradle 更换阿里云镜像的方法

    使用 Android Studio 开发时经常遇到编译卡住的问题,原因是 Gradle 下载依赖资源过慢.没办法,有长城在,还是得换镜像. 同样,这是个普遍存在的问题,我们希望可以对它进行全局配置.在 .gradle (路径参考 C:\Users\username\.gradle )目录下新增 init.gradle 文件,内容如下: allprojects{ repositories { def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/

  • Eclipse中配置Maven的图文教程

    一. 安装Maven 下载地址:http://maven.apache.org/检查 JAVA_HOME 环境变量. Maven 是使用 Java 开发的,所以必须知道当前系统环境中 JDK 的安装目录. 解压 Maven 的核心程序 将 apache-maven-3.6.3-bin.zip 解压到一个非中文无空格的目录下配置环境变量. 查看 Maven 版本信息验证安装是否正确 二.设置Maven的配置文件 1. 配置本地仓库 Maven 的核心程序并不包含具体功能,仅负责宏观调度.具体功能由

随机推荐