maven mirror

来源:互联网 发布:spss数据统计分析实例 编辑:程序博客网 时间:2024/05/17 07:12
网址:http://maven.oschina.net/help.html
1.修改 settings.xml

在 Maven 中使用 OSChina 的 Maven 服务还需要简单配置一下 Maven,在 Maven 的安装目录下的 conf 文件下有个  settings.xml  文件,接下来我们需要对这个文件做简单的修改,修改前您可以简单备份下该文件。 打开  settings.xml  文件,按下面内容修改。或者点击 settings.xml 下载


01<mirrors>
02    <!-- mirror | Specifies a repository mirror site to use instead of a given
03        repository. The repository that | this mirror serves has an ID that matches
04        the mirrorOf element of this mirror. IDs are used | for inheritance and direct
05        lookup purposes, and must be unique across the set of mirrors. | -->
06    <mirror>
07        <id>nexus-osc</id>
08        <mirrorOf>*</mirrorOf>
09        <name>Nexus osc</name>
10        <url>http://maven.oschina.net/content/groups/public/</url>
11    </mirror>
12</mirrors>

补充: 如果还需要osc的thirdparty仓库或多个仓库,需要如下修改:详情 
01<mirrors>
02    <!-- mirror | Specifies a repository mirror site to use instead of a given
03        repository. The repository that | this mirror serves has an ID that matches
04        the mirrorOf element of this mirror. IDs are used | for inheritance and direct
05        lookup purposes, and must be unique across the set of mirrors. | -->
06    <mirror>
07        <id>nexus-osc</id>
08        <mirrorOf>central</mirrorOf>
09        <name>Nexus osc</name>
10        <url>http://maven.oschina.net/content/groups/public/</url>
11    </mirror>
12    <mirror>
13        <id>nexus-osc-thirdparty</id>
14        <mirrorOf>thirdparty</mirrorOf>
15        <name>Nexus osc thirdparty</name>
16        <url>http://maven.oschina.net/content/repositories/thirdparty/</url>
17    </mirror>
18</mirrors>

这里是配置 Maven 的 mirror 地址指向OSChina 的 Maven 镜像地址。 在执行 Maven 命令的时候, Maven 还需要安装一些插件包,这些插件包的下载地址也让其指向 OSChina 的 Maven 地址。修改如下内容。


01<profile>
02    <id>jdk-1.4</id>
03 
04    <activation>
05        <jdk>1.4</jdk>
06    </activation>
07 
08    <repositories>
09        <repository>
10            <id>nexus</id>
11            <name>local private nexus</name>
12            <url>http://maven.oschina.net/content/groups/public/</url>
13            <releases>
14                <enabled>true</enabled>
15            </releases>
16            <snapshots>
17                <enabled>false</enabled>
18            </snapshots>
19        </repository>
20    </repositories>
21    <pluginRepositories>
22        <pluginRepository>
23            <id>nexus</id>
24            <name>local private nexus</name>
25            <url>http://maven.oschina.net/content/groups/public/</url>
26            <releases>
27                <enabled>true</enabled>
28            </releases>
29            <snapshots>
30                <enabled>false</enabled>
31            </snapshots>
32        </pluginRepository>
33    </pluginRepositories>
34</profile>

如果您需要修改 Maven 的默认文件保存路径,需要在 settings.xml 文件中修改如下地方。


1<localRepository>F:/Maven/repo/m2/</localRepository>

按照如上修改  settings.xml  之后,您就可以在自己的 Maven 中使用 OSChina 为您提供的 Maven 服务了。

0 0
原创粉丝点击