当前位置: 首页 > article >正文

nexus 快速搭建-本地私有仓库 -maven

场景:

  • 需要上传打包starer
  • 本地、局域网内 jar包上传、下载
  • 搭建后本地有层代理,可节省代宽,无网可拉包等…

下载: https://help.sonatype.com/repomanager3/product-information/download

  • 基本说明:
    • proxy 用来代理远程公共仓库,如 Maven中央仓库
    • hosted 本地仓库
    • group 仓库组,用来聚合代理仓库和宿主仓库

服务安装启动:

安装:nexus.exe /install local-mvn
启动:nexus.exe /start local-mvn
停止:nexus.exe /stop local-mvn
卸载:nexus.exe /uninstall local-mvn
默认配置:\etc\nexus-default.properties

默认访问地址:http://127.0.0.1:8081

初始admin密码:/sonatype-work/nexus3/admin.password

  • 登录后 修改 密码 admin123

settings - nexus.xml 配置,默认密码 admin123

<?xml version="1.0" encoding="UTF-8"?>
 
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at
    http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
-->
 
<!--
 | This is the configuration file for Maven. It can be specified at two levels:
 |
 |  1. User Level. This settings.xml file provides configuration for a single user,
 |                 and is normally provided in ${user.home}/.m2/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -s /path/to/user/settings.xml
 |
 |  2. Global Level. This settings.xml file provides configuration for all Maven
 |                 users on a machine (assuming they're all using the same Maven
 |                 installation). It's normally provided in
 |                 ${maven.conf}/settings.xml.
 |
 |                 NOTE: This location can be overridden with the CLI option:
 |
 |                 -gs /path/to/global/settings.xml
 |
 | The sections in this sample file are intended to give you a running start at
 | getting the most out of your Maven installation. Where appropriate, the default
 | values (values used when the setting is not specified) are provided.
 |
 |-->
<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
   | The path to the local repository maven will use to store artifacts.
   |
   | Default: ${user.home}/.m2/repository
  <localRepository>/path/to/local/repo</localRepository>
  -->
  <!--本地jar包存放路径 -->
  <localRepository>E:\environment\pub-repository</localRepository>
  <!-- interactiveMode
   | This will determine whether maven prompts you when it needs input. If set to false,
   | maven will use a sensible default value, perhaps based on some other setting, for
   | the parameter in question.
   |
   | Default: true
  <interactiveMode>true</interactiveMode>
  -->
 
  <!-- offline
   | Determines whether maven should attempt to connect to the network when executing a build.
   | This will have an effect on artifact downloads, artifact deployment, and others.
   |
   | Default: false
  <offline>false</offline>
  -->
 
  <!-- pluginGroups
   | This is a list of additional group identifiers that will be searched when resolving plugins by their prefix, i.e.
   | when invoking a command line like "mvn prefix:goal". Maven will automatically add the group identifiers
   | "org.apache.maven.plugins" and "org.codehaus.mojo" if these are not already contained in the list.
   |-->
  <pluginGroups>
    <!-- pluginGroup
     | Specifies a further group identifier to use for plugin lookup.
    <pluginGroup>com.your.plugins</pluginGroup>
    -->
  </pluginGroups>
 
  <!-- proxies
   | This is a list of proxies which can be used on this machine to connect to the network.
   | Unless otherwise specified (by system property or command-line switch), the first proxy
   | specification in this list marked as active will be used.
   |-->
  <proxies>
    <!-- proxy
     | Specification for one proxy, to be used in connecting to the network.
     |
    <proxy>
      <id>optional</id>
      <active>true</active>
      <protocol>http</protocol>
      <username>proxyuser</username>
      <password>proxypass</password>
      <host>proxy.host.net</host>
      <port>80</port>
      <nonProxyHosts>local.net|some.host.com</nonProxyHosts>
    </proxy>
    -->
  </proxies>
 
  <!-- servers
   | This is a list of authentication profiles, keyed by the server-id used within the system.
   | Authentication profiles can be used whenever maven must make a connection to a remote server.
   |-->
  <servers>
    <!-- server
     | Specifies the authentication information to use when connecting to a particular server, identified by
     | a unique name within the system (referred to by the 'id' attribute below).
     |
     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are
     |       used together.
     |
    <server>
      <id>deploymentRepo</id>
      <username>repouser</username>
      <password>repopwd</password>
    </server>
    -->
 
    <!-- Another sample, using keys to authenticate.
    <server>
      <id>siteServer</id>
      <privateKey>/path/to/private/key</privateKey>
      <passphrase>optional; leave empty if not used.</passphrase>
    </server>
    -->
	<server>
      <id>releases</id>  <!--对应pom.xml的id=releases的仓库-->
      <username>admin</username>
      <password>admin123</password>
    </server>
     <server>
      <id>snapshots</id> <!--对应pom.xml中id=snapshots的仓库-->
      <username>admin</username>
      <password>admin123</password>
	</server>
	<server>
      <id>nexus-ma</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
 	
  </servers>
 
  <!-- mirrors
   | This is a list of mirrors to be used in downloading artifacts from remote repositories.
   |
   | It works like this: a POM may declare a repository to use in resolving certain artifacts.
   | However, this repository may have problems with heavy traffic at times, so people have mirrored
   | it to several places.
   |
   | That repository definition will have a unique id, so we can create a mirror reference for that
   | repository, to be used as an alternate download site. The mirror site will be the preferred
   | server for that repository.
   |-->
  <mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
	 <mirror>
        <id>nexus-ma</id>
        <name>internal nexus repository</name>
        <!--maven私服镜像地址-->
        <url>http://127.0.0.1:8081/repository/maven-public/</url>
        <mirrorOf>*</mirrorOf>
    </mirror>
	
	<mirror>
		<id>nexus-aliyun</id>
		<mirrorOf>central</mirrorOf>
		<name>Nexus aliyun</name>
		<url>http://maven.aliyun.com/nexus/content/groups/public</url>
	</mirror>
	
  </mirrors>
 
  <!-- profiles
   | This is a list of profiles which can be activated in a variety of ways, and which can modify
   | the build process. Profiles provided in the settings.xml are intended to provide local machine-
   | specific paths and repository locations which allow the build to work in the local environment.
   |
   | For example, if you have an integration testing plugin - like cactus - that needs to know where
   | your Tomcat instance is installed, you can provide a variable here such that the variable is
   | dereferenced during the build process to configure the cactus plugin.
   |
   | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles
   | section of this document (settings.xml) - will be discussed later. Another way essentially
   | relies on the detection of a system property, either matching a particular value for the property,
   | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a
   | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'.
   | Finally, the list of active profiles can be specified directly from the command line.
   |
   | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact
   |       repositories, plugin repositories, and free-form properties to be used as configuration
   |       variables for plugins in the POM.
   |
   |-->
  <profiles>
    <!-- profile
     | Specifies a set of introductions to the build process, to be activated using one or more of the
     | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/>
     | or the command line, profiles have to have an ID that is unique.
     |
     | An encouraged best practice for profile identification is to use a consistent naming convention
     | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc.
     | This will make it more intuitive to understand what the set of introduced profiles is attempting
     | to accomplish, particularly when you only have a list of profile id's for debug.
     |
     | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo.
    <profile>
      <id>jdk-1.4</id>
      <activation>
        <jdk>1.4</jdk>
      </activation>
      <repositories>
        <repository>
          <id>jdk14</id>
          <name>Repository for JDK 1.4 builds</name>
          <url>http://www.myhost.com/maven/jdk14</url>
          <layout>default</layout>
          <snapshotPolicy>always</snapshotPolicy>
        </repository>
      </repositories>
    </profile>
    -->
	
 
    <!--
     | Here is another profile, activated by the system property 'target-env' with a value of 'dev',
     | which provides a specific path to the Tomcat instance. To use this, your plugin configuration
     | might hypothetically look like:
     |
     | ...
     | <plugin>
     |   <groupId>org.myco.myplugins</groupId>
     |   <artifactId>myplugin</artifactId>
     |
     |   <configuration>
     |     <tomcatLocation>${tomcatPath}</tomcatLocation>
     |   </configuration>
     | </plugin>
     | ...
     |
     | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to
     |       anything, you could just leave off the <value/> inside the activation-property.
     |
    <profile>
      <id>env-dev</id>
      <activation>
        <property>
          <name>target-env</name>
          <value>dev</value>
        </property>
      </activation>
      <properties>
        <tomcatPath>/path/to/tomcat/instance</tomcatPath>
      </properties>
    </profile>
    -->
	<profile>
  <!--ID用来确定该profile的唯一标识-->
           <id>jdk-1.8</id>
           <activation>
               <activeByDefault>true</activeByDefault>
               <jdk>1.8</jdk>
           </activation>
           <properties>
               <maven.compiler.source>1.8</maven.compiler.source>
               <maven.compiler.target>1.8</maven.compiler.target>
               <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
           </properties>
   </profile>
 
    <profile>
  <id>nexus-pr</id>
   <!-- 远程仓库列表 -->
  <repositories>
    <repository>
      <id>nexus-ma</id>
      <name>Nexus Central</name>
     <!-- 虚拟的URL形式,指向镜像的URL-->
      <url>http://127.0.0.1:8081/repository/maven-public/</url>
      <layout>default</layout>
     <!-- 表示可以从这个仓库下载releases版本的构件-->  
      <releases>
        <enabled>true</enabled>
      </releases>
     <!-- 表示可以从这个仓库下载snapshot版本的构件 -->  
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
    </repository>
  </repositories>
   <!-- 插件仓库列表 -->
  <pluginRepositories>
    <pluginRepository>
      <id>nexus-ma</id>
      <name>Nexus Central</name>
      <url>http://127.0.0.1:8081/repository/maven-public/</url>
      <layout>default</layout>
      <snapshots>
        <enabled>true</enabled>
      </snapshots>
      <releases>
         <enabled>true</enabled>
      </releases>
    </pluginRepository>
  </pluginRepositories>
   </profile>
  </profiles>
 
  <activeProfiles>
     <!--需要激活 <profile>中的ID才生效-->  
    <activeProfile>nexus-pr</activeProfile>
    <activeProfile>jdk-1.8</activeProfile>
  </activeProfiles>
 
 
 
  <!-- activeProfiles
   | List of profiles that are active for all builds.
   |
  <activeProfiles>
    <activeProfile>alwaysActiveProfile</activeProfile>
    <activeProfile>anotherAlwaysActiveProfile</activeProfile>
  </activeProfiles>
  -->
 
</settings>

nexus 基本配置:

建aliyun 代理库:

  • 地址 :http://maven.aliyun.com/nexus/content/groups/public
  • 名称:aliyun-proxy在这里插入图片描述
    在这里插入图片描述
    在这里插入图片描述

本地jar 上传:
在这里插入图片描述
1


http://www.kler.cn/news/106966.html

相关文章:

  • 浅谈数据结构之队列
  • win10安装Tensorflow(2.10-)使用最新cuda(12+),cudnn(8.9+)
  • OpenCV C++ 图像处理实战 ——《缺陷检测》
  • 【vim 学习系列文章 12 -- vimrc 那点事】
  • 05 MIT线性代数-转置,置换,向量空间Transposes, permutations, spaces
  • ant design vue 的getPopupContainer
  • 【Python机器学习】零基础掌握IsolationForest集成学习
  • Oracel增加IP白名单限制
  • uni-app小程序,uview-ui组件样式无法穿透修改的解决办法
  • 尚未解决:use_python()和use_virtualenv()的使用
  • vue3使用ref和reactive
  • uni-app/vue 文字转语音朗读(附小程序语音识别和朗读)uniapp小程序使用文字转语音播报类似支付宝收款播报小程序语音识别和朗读)
  • Python基础入门例程18-NP18 生成数字列表(列表)
  • 【2024秋招】2023-9-16 贝壳后端开发二面
  • 计算机网络重点概念整理-第一章 计算机网络概述【期末复习|考研复习】
  • 走进国产机器人领军品牌华数机器人,共探数字化变革魔力
  • 智慧停车视频解决方案:如何让AI助力停车管理升级?
  • 垃圾收费站
  • 《动手学深度学习 Pytorch版》 10.3 注意力评分函数
  • python实现批量pdf转txt和word
  • CVE-2022-32991靶场复现
  • 竞赛 深度学习实现行人重识别 - python opencv yolo Reid
  • Win10+Ubuntu20.04双系统双硬盘(SSD+HDD)安装与启动
  • 前端使用 printJS 插件打印多页:第一页空白问题解决
  • 数据结构与算法之矩阵: Leetcode 134. 螺旋矩阵 (Typescript版)
  • Spring Boot集成RESTful API
  • el-table添加固定高度height后高度自适应
  • 【前端】NodeJS核心知识点整理
  • Git(SourceTree)变基操作使用
  • 配置Sentinel 控制台