`
growinglin
  • 浏览: 9118 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Maven使用--setting.xml配置(转载)

阅读更多

Maven使用--setting.xml配置(转载)

http://www.360doc.com.cn/showWeb/0/0/381623.aspx

 

配置:

打开 ${maven.home}/conf 下面的 Setting.xml ,为了大家对照方便,我只在原来的基础上更改,顺序按从上往下

 

配置本地 Repository

<!-- 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 ,当需要输入参数时 Maven 会提示用户输入参数,如果设置为 false ,则在遇到有输入参数时不会提示用户, Maven 会自己生成一些参数,这样可能会出错,一般不需要改变默认设置。

 

是否连接互联网

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

-->

 

当运行的时候,决定 Maven 是否尝试与网络建立连接。这样可能会对已有的本地储藏室中的自定义 .jar 文件产生影响,默认为 false ,一般不需要改。

 

配置代理服务器(如果你使用代理服务器上网的话)

<!-- 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><!--代理服务器ID,可随意命名-->

<active>true</active><!-- 是否启用 -->

<protocol>http</protocol><!-- 通信协议 -->

<username>proxyuser</username><!-- 代理服务器用户名 -->

<password>proxypass</password><!-- 代理服务器密码 -->

<host>proxy.host.net</host><!-- 代理服务器主机地址 -->

<port>80</port><!-- 通信端口 -->

<nonProxyHosts></nonProxyHosts>

</proxy>

</proxies>

 其中 proxy.host.net 是你的代理服务器主机地址

 

展开我的项目到远程服务器

Pom .xml 文件:

<distributionManagement>

<repository>

<id>mycompany-repository
</id>

<name>MyCompany Repository</name>

<url>scp://repository.mycompany.com/repository/maven2</url>

</repository>

</distributionManagement>

 

Settings.xml

 

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

注意红色代码部分;

 

设置多个远程镜像

Java代码 复制代码 收藏代码
  1. <mirrors>   
  2.   
  3.     <!-- mirror   
  4.            
  5.         | Specifies a repository mirror site to use instead of a given repository. The repository that   
  6.            
  7.         | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used   
  8.            
  9.         | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.   
  10.            
  11.         |   
  12.            
  13.     -->   
  14.   
  15.     <mirror>   
  16.   
  17.         <id>ggi-project.org</id>   
  18.   
  19.         <url>http://ftp.ggi-project.org/pub/packages/maven2</url>   
  20.   
  21.         <mirrorOf>central</mirrorOf>   
  22.   
  23.     </mirror>   
  24.   
  25.     <mirror>   
  26.   
  27.         <id>planetmirror.com</id>   
  28.   
  29.         <url>http://public.planetmirror.com/pub/maven2</url>   
  30.   
  31.         <mirrorOf>central</mirrorOf>   
  32.   
  33.     </mirror>   
  34.   
  35.     <mirror>   
  36.   
  37.         <id>lsu.edu</id>   
  38.   
  39.         <url>http://ibiblio.lsu.edu/main/pub/packages/maven2</url>   
  40.   
  41.         <mirrorOf>central</mirrorOf>   
  42.   
  43.     </mirror>   
  44.   
  45.     <mirror>   
  46.   
  47.         <id>ibiblio.net</id>   
  48.   
  49.         <url>http://www.ibiblio.net/pub/packages/maven2</url>   
  50.   
  51.         <mirrorOf>central</mirrorOf>   
  52.   
  53.     </mirror>   
  54.   
  55. </mirrors>  
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics