maven 国内镜像

maven的默认的中央仓库为:maven.apache.org ,当本地仓库或者自己的maven 私服不存在相关的jar时,如没有特别设置,就去检查maven中央仓库有没有。

由于连接国外网站时网速特慢,为解决这个问题,os china 建立了一个maven 的私服。为了记忆,特将此记录。

settings.xml 设置镜像方法步骤如下:
1. mirrors 设置

<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>nexus-osc</id>
        <mirrorOf>central</mirrorOf>
        <name>Nexus osc</name>
        <url>http://maven.oschina.net/content/groups/public/</url>
    </mirror>
    <mirror>
        <id>nexus-osc-thirdparty</id>
        <mirrorOf>thirdparty</mirrorOf>
        <name>Nexus osc thirdparty</name>
        <url>http://maven.oschina.net/content/repositories/thirdparty/</url>
    </mirror>
</mirrors>

2. repositories 设置

<profile>
                <id>jdk-1.4</id>

                <activation>
                    <jdk>1.4</jdk>
                </activation>

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

详细信息可查看:http://maven.oschina.net/help.html

你可能感兴趣的:(maven)