Maven安装完成之后的配置

Maven安装完成之后,在conf/setting.xml中(可以把setting.xml复制到自己的用户目录下更改,以便每个用户的配置都能自定义) 1.配置本地仓库地址,从远程仓库下载的jar包会保存到这个目录,默认会在用户目录;建议自定义目录,方便管理: 
    <localRepository>/home/daniel/Tools/Maven/repo</localRepository> 
2.在mirrors节点中添加远程仓库地址,可多个,以oschina的仓库为例: id, name是该镜像的唯一定义符。id用来区分不同的mirror元素。url是该镜像的URL。构建系统会优先考虑使用该URL,而非使用默认的服务器URL。 mirrorOf是被镜像的服务器的id。

例如,如果我们要设置了一个Maven中央仓库( http:// repo1.maven.org/maven2)的镜像,就需要将该元素设置成central。这必须和 中央仓库的id central完全一致。 
    <mirror>         
        <id>nexus-osc</id>         
        <mirrorOf>*</mirrorOf>         
        <name>Nexus osc</name>         
        <url>http://maven.oschina.net/content/groups/public/</url>     
    </mirror>
3.执行maven时还需要一些插件,下面时配置这些插件的下载地址,和maven默认JDK版本,在profiles节点添加profile
    <profile>
        <id>jdk1.7</id>
        <activation>
            <activeByDefault>true</activeByDefault>
            <jdk>1.7</jdk>
        </activation>
        <properties>
            <maven.compiler.source>1.7</maven.compiler.source>
            <maven.compiler.target>1.7</maven.compiler.target>
            <maven.compiler.compilerVersion>1.7</maven.compiler.compilerVersion>
        </properties>
        <repositories>
            <repository>
                <id>nexus</id>
                <name>local private nexus</name>
                <url>http://maven.oschina.net/content/groups/public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </repository>
        </repositories>
        <pluginRepositories>
            <pluginRepository>
                <id>nexus</id>
                <name>local private nexus</name>
                <url>http://maven.oschina.net/content/groups/public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </profile>

转载于:https://my.oschina.net/jsw5297/blog/664525

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值