配置:
打開(kāi)${maven.home}/conf下面的Setting.xml,為了大家對照方便,我只在原來(lái)的基礎上更改,順序按從上往下
配置本地Repository(儲藏室)
<settings>
<!-- localRepository
| The path to the local repository maven will use to store artifacts.
|
| Default: ~/.m2/repository
-->
<localRepository>E:/LoaclRepository/m2</localRepository>
其中E:/LoaclRepository/m2是本地Repository,這個(gè)必須時(shí)絕對路徑。如果不改的話(huà)默認路徑是在C:Documents and Settings%username%.m2下。其中%username%為操作系統登錄用戶(hù)名,這樣不方便維護。
與用戶(hù)的交互模式
<!-- 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>
-->
默認為true,當需要輸入參數時(shí)Maven會(huì )提示用戶(hù)輸入參數,如果設置為false,則在遇到有輸入參數時(shí)不會(huì )提示用戶(hù),Maven會(huì )自己生成一些參數,這樣可能會(huì )出錯,一般不需要改變默認設置。
是否連接互聯(lián)網(wǎng)
<!-- 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>
-->
當運行的時(shí)候,決定 Maven 是否嘗試與網(wǎng)絡(luò )建立連接。這樣可能會(huì )對已有的本地儲藏室中的自定義.jar文件產(chǎn)生影響,默認為false,一般不需要改。
配置代理服務(wù)器(如果你使用代理服務(wù)器上網(wǎng)的話(huà))
<!-- 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> <!--代理服務(wù)器ID,可隨意命名-->
<active>true</active> <!-- 是否啟用 -->
<protocol>http</protocol> <!-- 通信協(xié)議 -->
<username>proxyuser</username> <!-- 代理服務(wù)器用戶(hù)名 -->
<password>proxypass</password> <!-- 代理服務(wù)器密碼 -->
<host>proxy.host.net</host> <!-- 代理服務(wù)器主機地址 -->
<port>80</port> <!-- 通信端口 -->
<nonProxyHosts></nonProxyHosts>
</proxy>
</proxies>
其中proxy.host.net是你的代理服務(wù)器主機地址
展開(kāi)我的項目到遠程服務(wù)器
Pom文件:
<distributionManagement>
<repository>
<id>mycompany-repository</id>
<name>MyCompany Repository</name>
<url>scp://repository.mycompany.com/repository/maven2</url>
</repository>
<!-- 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. -->
<id>mycompany-repository</id>
<username>jvanzyl</username>
<!-- Default value is ~/.ssh/id_dsa -->
<privateKey>/path/to/identity</privateKey> (default is ~/.ssh/id_dsa)
<passphrase>my_key_passphrase</passphrase>
</servers>
注意紅色代碼部分;
設置多個(gè)遠程鏡像
<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>ggi-project.org</id>
<url>http://ftp.ggi-project.org/pub/packages/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>planetmirror.com</id>
<url>http://public.planetmirror.com/pub/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>lsu.edu</id>
<url>http://ibiblio.lsu.edu/main/pub/packages/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>ibiblio.net</id>
<url>http://www.ibiblio.net/pub/packages/maven2</url>
<mirrorOf>central</mirrorOf>
</mirror>
</mirrors>
這樣可以設置多個(gè)鏡像,加快下載速度