eclipse 如何修改maven插件本地仓库jar包默认存储位置

CreateTime--2018年4月18日11:04:47

Author:Marydon

1.更改eclipse的maven本地仓库jar包保存位置

  Eclipse-->Windows-->Preferences-->Maven-->User Settings-->

  从网上的中心仓库下载下来的jar包,默认保存在了:C:\Users\Administrator\.m2\repository目录下,

从磁盘上打开该文件夹-->

  -->很明显,我的下面已经下载了项目中很多正在使用的jar包-->下面需要进行迁移,分为2个步骤:

第一步:迁移

  重新指定本地仓库位置为:D:\repository-maven,将repository文件夹直接剪切,粘贴到d盘根目录下,重命名为:repository-maven。

第二步:修改位置

  要想修改eclipse中本地仓库默认存储位置,则必须通过修改settings.xml文件来实现(有且只有这一种方法);

  你会发现,settings.xml的默认存在于C:\Users\Administrator\.m2目录下,但是该目录下面并没有该文件,

  方式一:推荐使用

    搭建maven运行环境,并修改conf/settings.xml,eclipse指定该settings.xml所在路径-->剩余步骤同下。

  方式二:

  将下面内容进行拷贝,然后保存名称为settings.xml,

  将该文件保存在D:\repository-maven目录下;

<?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.home}/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: ~/.m2/repository
<localRepository>/path/to/local/repo</localRepository>
--> <localRepository>C:\Users\Administrator\.m2\repository</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
| 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>
--> <!--
| 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>

  找到<localRepository>标签-->该标签指定了本地标签的保存位置-->将其改为:D:\repository-maven;

  修改settings.xml文件的位置;

  eclipse-->点击右侧的Browse..按钮-->选择settings.xml所在路径-->你会发现本地仓库位置已经发生变更-->点击"Apply"即可。

2.修改maven资源库下载地址(默认的中心仓库)

  默认是从maven资源库的官网地址:http://mvnrepository.com 下载jar包到本地,

但是我们也可以自行修改从别的地方下载jar包,比如:阿里,http://maven.aliyun.com/nexus/content/groups/public

方法:将配置文件中指定mirror的部分由默认修改为阿里即可。

步骤:

  打开setting.xml-->将下面代码拷贝到mirrors标签-->

<mirror>
<id>nexus-aliyun</id>
<mirrorOf>central</mirrorOf>
<name>Nexus aliyun</name>
<url>http://maven.aliyun.com/nexus/content/groups/public</url>
</mirror>

  -->Eclipse-->Windows-->Preferences-->Maven-->User Settings-->点击"Update Settings"即可。

 

eclipse 如何修改maven插件本地仓库jar包默认存储位置的更多相关文章

  1. [Maven]修改Maven的本地仓库路径

    安装Maven后我们会在用户目录下发现.m2 文件夹.默认情况下,该文件夹下放置了Maven本地仓库.m2/repository.所有的Maven构件(artifact)都被存储到该仓库中,以方便重用 ...

  2. Maven学习——修改Maven的本地仓库路径

    安装Maven后我们会在用户目录下发现.m2 文件夹.默认情况下,该文件夹下放置了Maven本地仓库.m2/repository.所有的Maven构件(artifact)都被存储到该仓库中,以方便重用 ...

  3. 修改Maven的本地仓库地址

    已经配置好的设定文件: 1.创建一个本地仓库的地址 2.修改Maven中conf目录下的settings.xml文件 在此处添加修改后的本地仓库的地址   3.打开cmd 输入mvn help:sys ...

  4. eclipse下使用maven配置库托管jar包

    1.项目是通过maven配置库托管jar包 首先要保证maven配置库中有相应的jar包才能通过这个方法来添加jar包.maven的有点就是把要用到的jar包统一放在一个配置库中,在某个项目需要用到这 ...

  5. Maven学习——安装与修改Maven的本地仓库路径

    一.Maven的下载安装配置 1.1.下载 官网 http://maven.apache.org/download.cgi 1.2.安装配置 apache-maven-3.3.3-bin.zip 解压 ...

  6. Maven学习——1、安装与修改Maven的本地仓库路径

    1.1.下载 官网 http://maven.apache.org/download.cgi 1.2.安装配置 apache-maven-3.3.3-bin.zip 解压下载的压缩包 1.3.配置环境 ...

  7. 设置eclipse的Maven插件引入依赖jar包后自动下载并关联相应的源码(转)

    好多用 Maven 的时候会遇到这样一个棘手的问题: 就是添加依赖后由于没有下载并关联源码,导致自动提示无法出现正确的方法名,而且不安装反编译器的情况下不能进入方法内部看具体实现 . 其实 eclip ...

  8. 如何将下载到本地的JAR包手动添加到Maven仓库,妈妈再也不用担心我下载不下来依赖啦

    我们有时候使用maven下载jar包的时候,可能maven配置都正确,但是部分jar包就是不能下载下来,如果maven设置都不正确的,可以查看我的maven系列文章,这里仅针对maven配置正确,但是 ...

  9. Maven配置本地仓库

    当我们在myeclipse中update maven时可能会报错User setting file does not exist C:\Users\lenevo\.m2\setting.xml,以致于 ...

随机推荐

  1. mysql ga rc beta alpha区别

    alpha  暗示这是一个以展示新特性为目的的版本,存在比较多的不稳定因素,还会向代码中添加新新特性 beta 以后的beta版.发布版或产品发布中,所有API.外部可视结构和SQL命令列均不再更改, ...

  2. PHP个人博客系统开发历程

    声明: Author:GenialX GenialX's QQ:2252065614 GenialX's URL:胡旭博客 - www.ihuxu.com 一年多曾经的某一天,我在上交实验报告时,偶然 ...

  3. C#程序集系列08,设置程序集版本

    区别一个程序集,不仅仅是程序集名称,还包括程序集版本.程序集公匙.程序集文化等,本篇体验通过界面和编码设置程序集版本. □ 通过Visual Studio设置程序集版本 →右键项目,选择"属 ...

  4. xcode4.3.2 arc模式下导入非arc的文件 转

    在arc模式下,我们经常会用到非arc的类库,此时我们可以在Compile Sources下对该文件进行编辑加入 -fno-objc-arc   如图中所示,就可以使用非arc的类库了   转:htt ...

  5. UIView 精要概览(持续更新)

    --1-- 知识点:为UIView 设置圆角 前提:layer 属性需要 <QuartzCore/QuartzCore.h> 静态库的支持,所以需要提前导入到项目中,并在你的文件中包含#i ...

  6. Facebook数据库工具Flashcache初探

    Flashcache是Facebook技术团队的又一力作,最初是为加速MySQL设计的.Flashcache是在Linux层面的,所以任何受磁盘IO困绕的软件或应用都可以方便的使用之. 1. Why ...

  7. cout的输出格式初探3

    #include <iostream> #include <iomanip> using namespace std; int main() { double f=2.0/3. ...

  8. nginx缓存和flask_cache

    1.使用flask_cache的缓存功能simple模式时,直接启用可以使用,但是如果中间使用nginx代理时,就没有效果了 2.那就直接使用nginx缓存机制 http://blog.csdn.ne ...

  9. 【计算机网络】详解网络层(二)ARP和RARP

    ARP ARP(Address Resolution Protocol,地址解析协议)是将IP地址解析为以太网MAC地址(物理地址)的协议.在局域网中,当主机或其他网络设备有数据要发送给另一个主机或设 ...

  10. retrofit okhttp RxJava bk Gson Lambda 综合示例【配置】

    项目地址:https://github.com/baiqiantao/retrofit2_okhttp3_RxJava_butterknife.git <uses-permission andr ...