maven+nexus配置本地私有仓库

以下是settting.xml的配置

<?xml version="1.0" encoding="UTF-8"?>
<settings> 
<localRepository>C:\Users\hankk\.m2\repository</localRepository><!--需要改成自己的maven的本地仓库地址-->
    <mirrors>
        <mirror>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
            <mirrorOf>central</mirrorOf>
        </mirror>
    </mirrors>
  <profiles>
    <profile>
       <id>maven-public-group</id> 
        <repositories>
            <repository>
                <id>maven-public-group</id>
                <name>maven-public-group</name>
                <url>http://10.117.150.34:30881/repository/maven-public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>false</enabled>
                </snapshots>
            </repository>
        </repositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>maven-public-group</activeProfile>
  </activeProfiles>
  <servers>
    <server>
        <id>maven-public-group</id>
        <username>bmitest</username>
        <password>bmitest</password>
    </server>
  </servers>
</settings>

配置完成后,发现其实下载的jar包,都是通过我们的私有仓库地址访问的,配置的aliyun服务器的地址其实并没有起作用,这里maven应该是有一个优先级的配置。

<id>maven-public-group</id>  这里的名字是随意起的,但是要和activeprofile和server里的id名字对应上,否则会失败。

用户名和密码和在nexus里配置好,否则会报401 未授权。

上传第三方jar包的maven命令:

mvn deploy:deploy-file -DgroupId=com.oracle -DartifactId=ojdbc6 -Dversion=11.2.0.1.0 -Dpackaging=jar -Dfile=ojdbc6.jar -Durl=http://10.117.150.34:***/repository/maven3rdparty/ -DrepositoryId=maven3rdparty

这里的maven3rdparty是创建的一个专业存储第三方jar包的仓库。maven-public仓库是一个group, 外面的系统是通过这个group访问的。

猜你喜欢

转载自www.cnblogs.com/hankuikui/p/10438799.html
今日推荐