• maven配置nexus私服详解


    简介:

    前提是已经搭建好了私服,我们需要在本地maven中配置相关参数,连接私服作为仓库;

    配置步骤

    1、本地maven settings.xml配置

    1.1配置本地仓库位置

    本地仓库配置,建议配置在.m2文件夹下

     <localRepository>C:\Users\lele\.m2\repositorylocalRepository>
    
    • 1

    在这里插入图片描述

    1.2 server配置

    主要为使用的ID单独配置账号密码;
    这个id标签的名字自定义唯一即可,在后面的步骤中为使用到。

      <servers>
        
        <server> 
        <id>maven-releasesid> 
        <username>your-usernameusername> 
        <password>your-passwordpassword> 
        server> 
      
        <server> 
        <id>maven-snapshotsid> 
        <username>your-usernameusername> 
        <password>your-passwordpassword> 
        server>  
      
        <server> 
        <id>maven-publicid> 
        <username>your-usernameusername> 
        <password>your-passwordpassword> 
        server> 
      servers>
      
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21

    1.3 镜像配置

    标签:要和上一步 标签中配置的一致;这样去连接镜像时才能获取到通过账号密码连接;

    标签:名称自定义
    标签: 私服中maven-public的地址
    标签: 指定为 central

      <mirrors>
        
        <mirror>
          <id>maven-publicid>
          <name>maven-publicname> 
          <url>http://ip:host/repository/maven-public/url>
          <mirrorOf>centralmirrorOf>
        mirror>
      mirrors>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    在这里插入图片描述

    1.4 私服仓库配置

    <profiles>
      <profile>
        
        <id>Nexusid>
           <repositories>
             <repository>
              <id>maven-publicid>
              <url>http://ip:host/repository/maven-public/url>
                <snapshots><enabled>trueenabled>snapshots>
                <releases><enabled>trueenabled>releases>
             repository>
           repositories>
                 
          <pluginRepositories>
            <pluginRepository>
                <id>maven-publicid>
                <url>http://ip:host/repository/maven-public/url>
                <snapshots><enabled>trueenabled>snapshots>
                <releases><enabled>trueenabled>releases>
            pluginRepository>
          pluginRepositories>   
         profile>
      profiles>
     
      <activeProfiles>
        <activeProfile>NexusactiveProfile>
      activeProfiles>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27

    在这里插入图片描述

    2、maven项目pom.xml配置

    自动提交jar进私服,pom.xml文件中添加
    id 要和setting.xml中配置的一致

        
        <distributionManagement>
            <repository>
                <id>maven-releasesid>
                <url>http://ip:host/repository/maven-releases/url>
            repository>
            <snapshotRepository>
                <id>maven-snapshotsid>
                <url>http://ip:host/repository/maven-snapshots/url>
            snapshotRepository>
        distributionManagement>
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    在这里插入图片描述

    运行mvn deploy即会提交jar进私服仓库。

    完整配置模板

    <settings xmlns="http://maven.apache.org/SETTINGS/1.2.0"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.2.0 http://maven.apache.org/xsd/settings-1.2.0.xsd">
     
      
      <localRepository>C:\Users\lele\.m2\repositorylocalRepository>
    
      
      <pluginGroups>
        
      pluginGroups>
    
      
      <proxies>
    
      proxies>
    
      <servers>
       
        <server> 
        <id>maven-releasesid> 
        <username>your-usernameusername> 
        <password>your_passwordpassword> 
        server> 
      
        <server> 
        <id>maven-snapshotsid> 
        <username>your-usernameusername> 
        <password>your_passwordpassword> 
        server>  
      
        <server> 
        <id>maven-publicid> 
        <username>your-usernameusername> 
        <password>your_passwordpassword> 
        server> 
      servers>
      
      <mirrors>
        
        <mirror>
          <id>maven-publicid>
          <name>maven-publicname> 
          <url>http://ip:host/repository/maven-public/url>
          <mirrorOf>centralmirrorOf>
        mirror>
      mirrors>
    
    <profiles>
      <profile>
        
        <id>Nexusid>
          
          <repositories>
             <repository>
                <id>maven-publicid>
                <url>http://ip:host/repository/maven-public/url>
                <snapshots><enabled>trueenabled>snapshots>
                <releases><enabled>trueenabled>releases>
             repository>
          repositories>
    
          
          <pluginRepositories>
            <pluginRepository>
                <id>maven-publicid>
                <url>http://ip:host/repository/maven-public/url>
                <snapshots><enabled>trueenabled>snapshots>
                <releases><enabled>trueenabled>releases>
            pluginRepository>
          pluginRepositories>      
      profile>
    profiles>
    
      <activeProfiles>
        <activeProfile>NexusactiveProfile>
      activeProfiles>
    settings>
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86

    maven标签 与详解

    maven将源码包和jar一起打包并上传到私服

  • 相关阅读:
    【HUAWEI】trunk和access两种链路模式实例
    SpikingJelly笔记之延迟编码
    嵌入式开发学习--进程、线程
    docker部署Jenkins与任务创建【七千字超详细指南】
    【GlobalMapper精品教程】021:利用控制点校正栅格图像
    基于AT89C51单片机与DS18B20的温度测量系统
    通用导出el-table表格内容的方法
    国庆作业day6
    LeetCode-435-无重叠区间
    PAT甲级刷题记录-(AcWing)-Day09数学(8题)
  • 原文地址:https://blog.csdn.net/weixin_43811057/article/details/132720550