1. 程式人生 > >Eclipse工程中配置Maven國內映象倉庫

Eclipse工程中配置Maven國內映象倉庫

從官網上下載jar檔案非常慢,可以通過修改pom.xml來設定國內的映象倉庫,提高下載速度。

pom.xml增加下列配置項:

	<repositories>
		<repository>
			<id>repo-mirror</id>
			<name> Maven China Mirror</name>
			<url>http://maven.net.cn/content/groups/public/</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
	</repositories>
	
	<pluginRepositories>
		<pluginRepository>
			<id>plugin-repo-mirror</id>
			<name> Maven China Mirror</name>
			<url>http://maven.net.cn/content/groups/public/</url>
			<releases>
				<enabled>true</enabled>
			</releases>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</pluginRepository>
	</pluginRepositories>

一勞永逸的做法是修改settings.xml配置檔案,對所有工程有效:

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

一個參考例項是以開源中國的Maven映象伺服器的參考配置如下:

 <mirrors>
    <mirror>
      <id>maven.net.cn</id>
      <name>one of the central mirrors in china</name>
      <url>http://maven.oschina.net/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>
    </mirror>
  </mirrors>

2016/11/25 最近國內的映象伺服器不可用,更新幾個可用的Maven映象伺服器:

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

如果有可用的代理伺服器,也可以在settings.xml裡設定代理伺服器:

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

參考資料:

相關推薦

Eclipse工程配置Maven國內映象倉庫

從官網上下載jar檔案非常慢,可以通過修改pom.xml來設定國內的映象倉庫,提高下載速度。 pom.xml增加下列配置項: <repositories> <repository> <id>repo-mirror</i

eclipse配置Maven與本地倉庫和阿里雲映象設定

eclipse中配置Maven 1 在window-preference中搜索maven 在1 Maven Installation 找到Maven安裝路徑的bin的路徑 2  User setting 找到Maven的setting 及本地倉庫 引入Maven

Eclipse配置Maven倉庫(阿里雲映象)

1. 先到http://maven.apache.org/下載Maven這裡下載了apache-maven-3.5.0-bin.zip2. 解壓apache-maven-3.5.0-bin.zip 到隨便一個地方, 依次開啟apache-maven-3.5.0\conf\ 找

【圖解】Windows下 apache-maven-3.2.3的安裝步驟+maven配置本地倉庫+Eclipse配置maven

安裝步驟: 1.在安裝maven之前,先確保已經安裝JDK1.6及以上版本,並且配置好環境變數。 3.配置maven3的環境變數:先配置M3_HOME的環境變數,新建一個系統變數:M3_HOME , 路徑是:E:\code\apache-maven-3.2.3

Eclipse配置Maven(阿里雲映象)

1. 先到http://maven.apache.org/下載Maven 這裡下載了apache-maven-3.5.0-bin.zip 2. 解壓apache-maven-3.5.0-bin.zip 到隨便一個地方, 依次開啟apache-maven-3.5.0\con

eclipse配置maven版本和maven倉庫

1.開啟eclipse  Window->Preferences 2.配置倉庫位置 這個位置在安裝的maven目錄下的conf目錄下  apache-maven-3.3.9\conf

Maven的安裝以及eclipse配置maven

  2、  下載下來之後,解壓,我是放在D盤:   3、  配置環境變數:(注意:配置這個之前必須先下載並安裝JDK,配置JDK的環境變數JAVA_HOME,否則maven將無法使用) (1)新建系統變數名:MAVEN_HOME 變數值:D:\M

如何進行JDK安裝\Maven安裝、在eclipse配置java環境、在eclipse配置Maven環境、在eclipse新建maven的web專案?

目錄 一、JDK安裝教程  JDK安裝教程 1.首先下載jdk安裝包,然後解壓安裝包tar -zxvf jdk-7u79-linux-x64.tar.gz 2.修改環境變數   在根目錄下使用命令:vi ./bash_profile   在此檔案中新

Eclipse配置Maven build打包

注意:[INFO] BUILD FAILURE [INFO] ------------------------------------------------------------------------ [INFO] Total time: 1.622 s [INFO] Finished at: 2016

maven國內映象配置(Ubuntu)

maven在apache的官方映象非常慢,嚴重影響速度,建議使用國內的映象。目前國內的映象較少,可以使用oschina的映象,具體配置過程參考: http://maven.oschina.net/static/help.html 上述安裝過程基於Windows環境,以下過程

Eclipse Maven工程缺少Maven Dependencies

Eclipse在引入Maven工程後,找不到Maven Dependencies。使得程式碼報錯,具體如下圖所示: 而正常Maven的工程如下所示: 產生這種現象的原因可能是工程對應的開發環境改變,本地Maven倉庫地址和原來的不一致。其根本原因是Maven pro

CentOS6.6系統安裝Maven以及Eclipse配置Maven

目錄 1. 虛擬機器中maven的安裝 2. eclipse中配置maven 1. 虛擬機器中maven的安裝        基於對大資料的學習,初步入手分散式、叢集開發,為了方便專案的建立和管理,這裡引進常用的maven來做管理。下面

如何在ecplise配置maven以及ecplise訪問本地倉庫

完成 window style 刷新 如果 index 安裝目錄 技術 插件 1.m2e的插件 因為使用ecplise版本比較高,所以它自帶了maven的插件,但是我們希望可以使用我們自己指定的maven。配置步驟如下: ecplise--->preperences下

Maven pom配置多個遠端倉庫

原文地址:http://www.xuebuyuan.com/1124933.html <repositories> <repository> <id>datanucleus</id> <url>

【圖文講解】eclipse配置maven環境+匯入maven專案

1.檢測eclipse是否有maven環境 開啟import對話窗輸入maven,如果下面紅色方框裡有東西可以跳過下一步的elipse中配置maven環境,如果方框裡沒有東西,按照下一步在eclipse中配置maven環境後即可出現 2.在eclipse中配置mave

eclipse配置maven 執行使用maven自帶的jetty

今天剛拿到手的專案 從前沒有用過maven和jetty終於配置好了寫個文章儲存下,也希望對想要配置的朋友有點幫助  首先在eclipse中安裝maven就不多說了 網上搜一下 一堆教程 安裝好的效果: 然後就是配置了,這裡需要注意的有兩個地方  第一個就是Installa

在pom.xml設定maven映象國內映象

總所周知的是國外的maven映象下載速度巨慢,對於新手學習maven來說,這是一個很痛苦的過程。 國內阿里雲的maven倉庫速度很快,下載速度槓槓的。 先說一下我的個人習慣,我有重灌系統的習慣,會把一下不需要安裝的軟體備份下來,maven就是一個例子,下載好maven之後,

Maven的安裝和在Eclipse配置Maven

簡介 Maven是Apache組織中的一個開源專案,翻譯成中文的意思是“專家”、“內行的意思”,主要用於Java平臺的專案構建、依賴管理和專案資訊管理。 Maven可以統一開發規範,還可以統一管理Ja

在STS(Spring Tool Suite)配置Maven,以及配置不成功的解決方案

Spring Tool Suite  Spring 專案快速開發的工具集合,簡稱sts。 主要用於快速的開發Spring專案,我們不用再去編輯繁瑣的xml配置檔案,而是由工具自動生成。   STS下載 1.可自行到官網下載,選擇需要版本下載 2.ST

pom.xml配置maven專案的JDK版本

預設版本 maven專案中,編譯器和JRE的版本預設為1.5(所以Alt + F5重新整理專案後,多個引數值會變成1.5) 引數如下(選中專案,Alt + Enter,檢視專案屬性): Java Build Path下的Libraries下的JRE System Lirbrary的版