首页 > 其他分享 >Nexus搭建实例

Nexus搭建实例

时间:2023-02-17 21:45:37浏览次数:30  
标签:http repository Nexus 192.168 maven nexus 实例 public 搭建

搭建服务

      

       

集成Maven

      配置本地maven的setting.xml文件

<?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">
  
<localRepository>F:\hzl_maven_repository</localRepository>
  
  <pluginGroups>
   
  </pluginGroups>
 
  
  <proxies>
   
  </proxies>
 
 
  <servers>
<!--第一个nexus-repo要和下面的mirror或profiles中的id一致,代表拉取是也需要进行身份校验-->
        <server>  
            <id>nexus-repo</id>  
            <username>admin</username>  
            <password>admin123</password>  
        </server>  
<!--这两个是jar上传时候进行的验证,id对应的是pom中id属性的值-->
        <server>  
            <id>maven-releases</id>  
            <username>admin</username>  
            <password>admin123</password>  
        </server>  
        <server>  
            <id>maven-snapshots</id>  
            <username>admin</username>  
            <password>admin123</password>  
        </server>  
  </servers>
 
  <mirrors>
    <!-- 这里配置策略是:优先从阿里云下载,下载不到时再从nexus下载 -->
    <mirror>  
      <id>alimaven</id>  
      <name>aliyun maven</name>  
      <url>https://maven.aliyun.com/repository/public/</url>  
      <mirrorOf>central</mirrorOf>          
    </mirror>
 
    <!--
    <mirror>
      <id>nexus</id>
      <name>nexus maven</name> 
      <url>http://192.168.1.169:8081/repository/maven-public/</url>
      <mirrorOf>nexus</mirrorOf>
    </mirror>
    -->
 
  </mirrors>
 
  <profiles>
    <profile>
        <id>nexus-repo</id>
        <repositories>
            <!-- 阿里远程仓库 -->
            <repository>
                <id>central</id>
                <url>https://maven.aliyun.com/repository/public/</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>false</enabled></snapshots>
            </repository>
 
            <!-- nexus仓库 -->
            <repository>
                <id>HzlNexus</id>
                <url>http://192.168.1.169:8081/repository/maven-public/</url>
                <releases>
                    <enabled>true</enabled><updatePolicy>always</updatePolicy>
                </releases>
                <snapshots>
                    <enabled>true</enabled><updatePolicy>always</updatePolicy>          
                </snapshots>
            </repository>
 
        </repositories>
 
        <pluginRepositories>
            <!-- 阿里远程仓库 -->
            <pluginRepository>
                <id>central</id>
                <url>https://maven.aliyun.com/repository/public/</url>
                <releases><enabled>true</enabled></releases>
                <snapshots><enabled>false</enabled></snapshots>
            </pluginRepository>
 
            <!-- nexus仓库 -->
            <pluginRepository>
                <id>HzlNexus</id>
                <url>http://192.168.1.169:8081/repository/maven-public/</url>
                <releases>
                    <enabled>true</enabled><updatePolicy>always</updatePolicy>
                </releases>
                <snapshots>
                   <enabled>true</enabled><updatePolicy>always</updatePolicy>
                </snapshots>
            </pluginRepository>
        </pluginRepositories>
 
    </profile>
  </profiles>
 
  <activeProfiles>
      <activeProfile>nexus-repo</activeProfile>
  </activeProfiles>
</settings>
setting.xml

 

     配置项目pom.xml

<!-- 配置jar向私服推送的仓库地址,推送时会根据版本不同推送到不同的仓库中  -->
<distributionManagement>
        <repository>
            <id>maven-releases</id>
            <name>Nexus Release Repository</name>
            <url>http://192.168.1.169:8081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>maven-snapshots</id><!--对应maven settings.xml中server的id-->
            <name>Nexus Snapshot Repository</name>
            <url>http://192.168.1.169:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
pom.xml

 

错误排查

         

         

         

        

        

        nexus使用自定义的jdk1.8,不使用系统安装的jdk11

        

        

      ./nexus run 启动成功

      

      

      

 

标签:http,repository,Nexus,192.168,maven,nexus,实例,public,搭建
From: https://www.cnblogs.com/yxh168/p/17131448.html

相关文章