Maven setting.xml配置文件详解

网友投稿 666 2023-03-09


Maven setting.xml配置文件详解

maven的配置文件settings.xml存在于两个地方:

1.安装的地方:${M2_HOME}/conf/settings.xml

2.用户的目录:${user.home}/.m2/settings.xml

前者又被叫做全局配置,对操作系统的所有使用者生效;后者被称为用户配置,只对当前操作系统的使用者生效。如果两者都存在,它们的内容将被合并,并且用户范围的settings.xml会覆盖全局的settings.xml。

Maven安装后,用户目录下不会自动生成settings.xml,只有全局配置文件。如果需要创建用户范围的settings.xml,可以将安装路径下的settings复制到目录${user.home}/.m2/。Maven默认的settings.xml是一个包含了注释和例子的模板,可以快速的修改它来达到你的要求。

全局配置一旦更改,所有的用户都会受到影响,而且如果maven进行升级,所有的配置都会被清除,所以要提前复制和备份${M2_HOME}/conf/settings.xml文件,一般情况下不推荐配置全局的settings.xml。

settings.xml详解

声明规范

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

localRepository

usr/local/maven

interactiveMode

true

usePluginRegistry

false

offline

false

pluginGroups

org.codehaus.mojo

proxies

myproxy

true

http

proxy.somewhere.com

8080

proxyuser

somepassword

*.google.com|ibiblio.org

servers

server001

my_login

my_password

${usr.home}/.ssh/id_dsa

some_passphrase

664

775

mirrors

planetmirror.com

PlanetMirror Australia

http://downloads.planetmirror.com/pub/maven2

central

profiles

test

Activation

false

1.5

Windows XP

Windows

x86

5.1.2600

mavenVersion

2.0.3

${basedir}/file2.properties

${basedir}/file1.properties

Properties

${user.home}/our-project

note:如果该profile被激活,则可以再POM中使用${user.install}。

Repositories

codehausSnapshots

Codehaus Snapshots

false

always

warn

http://snapshots.maven.codehaus.org/maven2

default

activeProfiles

env-test

xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

localRepository

usr/local/maven

interactiveMode

true

usePluginRegistry

false

offline

false

pluginGroups

org.codehaus.mojo

proxies

myproxy

true

http

proxy.somewhere.com

8080

proxyuser

somepassword

*.google.com|ibiblio.org

servers

server001

my_login

my_password

${usr.home}/.ssh/id_dsa

some_passphrase

664

775

mirrors

planetmirror.com

PlanetMirror Australia

http://downloads.planetmirror.com/pub/maven2

central

profiles

test

Activation

false

1.5

Windows XP

Windows

x86

5.1.2600

mavenVersion

2.0.3

${basedir}/file2.properties

${basedir}/file1.properties

Properties

${user.home}/our-project

note:如果该profile被激活,则可以再POM中使用${user.install}。

Repositories

codehausSnapshots

Codehaus Snapshots

false

always

warn

http://snapshots.maven.codehaus.org/maven2

default

activeProfiles

env-test


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:浅谈Java 并发的底层实现
下一篇:api接口文档有什么用(api接口文档是干什么的)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~