zoukankan      html  css  js  c++  java
  • maven配置私服仓库

    公司都有自己的私服仓库,配置之后可以提高下载速度,同时本公司自己项目的依赖都在私服仓库里,有些东西是外界无法访问的,仅仅是内部使用。

    私服是一种特殊的远程仓库,它是架设在局域网内的仓库服务,私服代理广域网上的远程仓库,供局域网内的Maven用户使用。当Maven需要下载构件的时候,它从私服请求,如果私服上不存在该构件,则从外部的远程仓库下载,缓存在私服上之后,再为Maven的下载请求提供服务。我们还可以把一些无法从外部仓库下载到的构件上传到私服上。

    比如你们公司的私服仓库地址是:http://nexus.company.com/repository/maven-public/

    那么就在pom.xml里配置

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <repositories>
            <repository>
                <id>nexus</id>
                <url>http://nexus.company.com/repository/maven-public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
    
        <pluginRepositories>
            <pluginRepository>
                <id>nexus</id>
                <url>http://nexus.company.com/repository/maven-public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </project>

    情况二:比如我要与A公司对接,对方提供了maven坐标,可是你引入后报错 找不到此依赖。那是因为你们的私服仓库以及中央仓库没有人家的私有项目。那就要对方提供他们的仓库地址,然后配置即可。

    比如对方地址为:http://artifactory.other-company.com/artifactory/maven/

    就要如下配置,也就是说,可以配置多个私服仓库。

    <?xml version="1.0" encoding="UTF-8"?>
    <project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
        xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
        <repositories>
            <repository>
                <id>nexus</id>
                <url>http://nexus.company.com/repository/maven-public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
            <repository>
                <id>nexus-other-company</id>
                <url>http://artifactory.other-company.com/artifactory/maven/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
        </repositories>
    
        <pluginRepositories>
            <pluginRepository>
                <id>nexus</id>
                <url>http://nexus.company.com/repository/maven-public/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
            <pluginRepository>
                <id>nexus-other-company</id>
                <url>http://artifactory.other-company.com/artifactory/maven/</url>
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
    </project>

    配置完你就可以正常引入别人的私有项目依赖了。

  • 相关阅读:
    继承
    类和对象
    Scanner类
    面向对象思想
    final关键字
    The difference between text mode and binary mode with file streams
    Linux下常见权限操作相关命令
    Failed to start component [StandardEngine[Catalina].StandardHost[localhost].StandardContext
    手动运行jar包,指定配置文件
    jdk 1.8.0_131 Class JavaLaunchHelper is implemented
  • 原文地址:https://www.cnblogs.com/LUA123/p/11383261.html
Copyright © 2011-2022 走看看