nexus maven私服搭建

Maven用到的Repositories说明
maven-central:maven中央库,默认从https://repo1.maven.org/maven2/拉取jar
maven-releases:私库发行版jar
maven-snapshots:私库快照(调试版本)jar(只需要在发布的版本号后面加上-SNAPSHOT
maven-public:仓库分组,把上面三个仓库组合在一起对外提供服务,在本地maven基础配置settings.xml中使用。

nexus3中央仓库改为阿里云


image.png

image.png

https://maven.aliyun.com/repository/central

配置文件

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
          xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd">

  <pluginGroups>
  </pluginGroups>

  <proxies>
 
  </proxies>

 
  <servers>
   <server>  
         <id>nexus-releases</id>  
         <username>admin</username>  
         <password>h*yi</password>  
     </server>  
     <server>  
         <id>nexus-snapshots</id>  
         <username>admin</username>  
         <password>h*yi</password>  
     </server> 
    <server>  
         <id>central</id>  
         <username>admin</username>  
         <password>h*yi</password>  
     </server>   
  </servers>

 
  <mirrors>
     <mirror>  
          <id>central</id>  
          <mirrorOf>*</mirrorOf>  
          <name>Central Repository</name>  
          <url>http://139.155.180.*:8081/repository/maven-public/</url>  
      </mirror> 
  </mirrors>

  
  <profiles>
    <profile>  
      <id>dev</id>
      <repositories>
        <repository>
          <id>Nexus</id>
          <url>http://139.155.180.*:8081/repository/maven-public/</url>
          <releases>
            <enabled>true</enabled>
          </releases>
          <snapshots>
            <enabled>true</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>
</profiles>

<activeProfiles>
    <activeProfile>dev</activeProfile>
</activeProfiles>

  
</settings>

发布包

 <distributionManagement>
        <repository>
            <id>nexus-releases</id>
            <name>Nexus Release Repository</name>
            <url>http://你的maven地址/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus-snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://你的maven地址/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
image.png

如果出现

from/to central (http://139.155.180.170:8081/repository/maven-public/): Not authorized

检查server对应的id和mirror的id是否一致

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容