2016-02-12 71 views
0

我有一個問題,因爲我想更改m2存儲庫路徑,我在Linux上我已經在我的settings.xml中添加了這個<localRepository>/tmp/m2Repo</localRepository>,但是當我執行命令mvn archetype:generate時,它下載了所有內容標準路徑。更改m2庫路徑

當我使用命令 mvn archetype:generate -Dmaven.repo.local=/tmp/m2Repo此命令

是成功的。我怎樣才能讓不使用命令行和成功-Dmaven.repo.local=/tmp/m2Repo

謝謝!

+0

作爲一個黑客,它可能會幫助移動'〜/ .m2'目錄'/ tmp'並添加符號鏈接。 –

+1

你編輯_ {} M2_HOME /conf/settings.xml_? – Berger

+0

你上哪兒去位於你的'settings.xml'?正確地在'$ HOME/.m2/settings.xml'中? – khmarbaise

回答

0

在有些情況下設置有兩個位置。請確定你使用哪一個。檢查manual,檢查文件屬性。

One is Maven install (global), second is inside user account. 
The settings element in the settings.xml file contains elements used to define values which configure Maven execution in various ways, like the pom.xml, but should not be bundled to any specific project, or distributed to an audience. These include values such as the local repository location, alternate remote repository servers, and authentication information. 

There are two locations where a settings.xml file may live: 

    The Maven install: $M2_HOME/conf/settings.xml 
    A user’s install: ${user.home}/.m2/settings.xml 

The former settings.xml are also called global settings, the latter settings.xml are referred to as user settings. If both files exists, their contents gets merged, with the user-specific settings.xml being dominant. 

Tip: If you need to create user-specific settings from scratch, it’s easiest to copy the global settings from your Maven installation to your ${user.home}/.m2 directory. Maven’s default settings.xml is a template with comments and examples so you can quickly tweak it to match your needs. 
0

您是否已經從您的MAVEN_HOME或M2_HOME環境變量中檢查了conf/settings.xml?