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

时间:2022-09-26 10:08:52
 

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

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

Author:Marydon

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

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

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

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

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

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

  -->很明显,我的下面已经下载了项目中很多正在使用的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;

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

  修改settings.xml文件的位置;

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

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

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. &lbrack;Maven&rsqb;修改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. xpath定位实战(1)

    1.执行scrapy shell "https://book.douban.com/subject/2256039/"

  2. 关于StrangeIOC框架

    在Unity上进行开发,请先看对其开发模式应用的讨论: http://www.reddit.com/r/Unity3D/comments/1nb06h/unity_design_patterns_an ...

  3. BZOJ树链剖分题目汇总

    1036,2157,2243,4034,4196;2325,2908,3083,3159,3531,3626,3999;可以不树剖:1146;2819,2843,4448,4530.

  4. 弱引用?强引用?未持有?额滴神啊-- Swift 引用计数指导

    ARC ARC 苹果版本的自动内存管理的编译时间特性.它代表了自动引用计数(Automatic Reference Counting).也就是对于一个对象来说,只有在引用计数为0的情况下内存才会被释放 ...

  5. Brainstorm in one sentence

    [1]佚名|*学生占领立法院 人會長大三次 第一次是發現世界不是為自己而轉的時候. 第二次是在發現即使再怎麼努力,終究還是有些事令人無能為力的時候. 第三次是在,明知道有些事可能會無能為力,但還是會 ...

  6. poj 3678 2-SAT问题

    思路:将每个点拆分为两个点 a与a' ,a表示为1,a'表示为0.那么条件给的每个边自然就会存在矛盾,然后根据2-SAT建边就行了. #include<iostream> #include ...

  7. MySQL5&period;5版本安装失败问题

    安装的时候前边都正常,总是到最后一步出问题.前几次是到最后一步没有响应,网上有一种方法是在安装MySQl的时候改变默认的服务名“MySQL”.但我试过这种方法,好几次都没成功. 这种情况下我用了第二种 ...

  8. mysql联合索引

    命名规则:表名_字段名1.需要加索引的字段,要在where条件中2.数据量少的字段不需要加索引3.如果where条件中是OR关系,加索引不起作用4.符合最左原则 https://segmentfaul ...

  9. Android 控件 之 Menu 菜单

    http://www.cnblogs.com/Mrs-cc/archive/2012/07/21/2603042.html 1.OptionsMenu (选项菜单)用法总结   使用方法: 方法一:添 ...

  10. Currency Exchange&lpar;判断是否有正环&rpar;

    Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 16456   Accepted: 5732 Description Seve ...