nexus3下載安裝配置運行

一、介紹

nexus是一個maven私服。

私服

私服是一種特殊的遠程倉庫,它是架設在局域網內的倉庫服務,私服代理廣域網上的遠程倉庫,供局域網內的用戶使用。當Maven需要下載構件的時候,它從私服請求,如果 私服上不存在該構件,則從外部遠程倉庫下載,緩存在私服上之後,再爲Maven的下載請求提供服務。
私服的好處:
a、節省自己的外網帶寬
b、加速Maven構建
c、部署自己內部的第三方構件
d、提高穩定性,增強控制
e、降低中央倉庫的負荷。

二、下載

網上很多文檔說官網下載慢,但是能下載,但是我一直沒下載下來,即使翻牆,也沒有成功下載,最後從國內csdn網友的分享下載的。這裏也分享一下:

鏈接:https://pan.baidu.com/s/1oN6p-v8r8kfHbaHUbtjEaA 
提取碼:bn50

nexus爲windows、osX、unix三個平臺提供支持。我分享的版本是:nexus-3.20.1-01-win64.rar

三、安裝

1、解壓壓縮包到指定文件夾,比如:D:\06.tools\nexus3,得到nexus-3.20.1-01文件夾和 sonatype-work 文件夾

nexus-3.16.2-01:是nexus服務器相關的文件

sonatype-work:是nexus工作的數據文件,上傳下載的jar包就在這個文件夾下面。

四、啓動

在命令提示符中進去D:\06.tools\nexus3\nexus-3.20.1-01\bin文件夾,執行命令:nexus /run,訪問http://localhost:8081

五、使用

nexus3的使用

1.登錄nexus

使用默認用戶admin,密碼admin123,登錄。

2.管理私服本地倉庫

2.1倉庫類型

Nexus有4個【類型】的數據倉庫,分別是hosted,proxy,group、virtual(基本不用)。

  • hosted 宿主倉庫:主要用於部署無法從公共倉庫獲取的構件以及自己或第三方的項目構件;
  • proxy 代理倉庫:代理公共的遠程倉庫;
  • group 倉庫組:Nexus 通過倉庫組統一管理多個倉庫,這樣我們在項目中直接請求倉庫組即可請求到倉庫組管理的多個倉庫。

 

Nexus默認的倉庫類型有以下四種:(上面的名字可以隨便取,關鍵是它對應的是什麼倉庫類型)

   1)group(倉庫組類型):又叫組倉庫,用於方便開發人員自己設定的倉庫;

   2)hosted(宿主類型):內部項目的發佈倉庫(內部開發人員,發佈上去存放的倉庫);

   3)proxy(代理類型):  從遠程中央倉庫中尋找數據的倉庫(可以點擊對應的倉庫的Configuration頁簽下Remote Storage Location屬性的值即被代理的遠程倉庫的路徑);

   4)virtual(虛擬類型): 虛擬倉庫(這個基本用不到,重點關注上面三個倉庫的使用);

Policy(策略):表示該倉庫爲發佈(Release)版本倉庫還是快照(Snapshot)版本倉庫;

2.2默認倉庫

Nexus預定義了2個本地倉庫,分別是maven-releases, maven-snapshots。

  • maven-releases:這裏存放我們自己項目中發佈的構建, 通常是Release版本的。
  • maven-snapshots:這個倉庫非常的有用, 它的目的是讓我們可以發佈那些非release版本, 非穩定版本。

默認倉庫介紹

   1)maven-central(proxy):      maven中央庫,默認從https://repo1.maven.org/maven2/拉取jar

   2)maven-releases(hosted):   私庫發行版jar

   3)maven-snapshots(hosted):私庫快照(調試版本)jar

   4)maven-public(group):     倉庫分組,把上面三個倉庫組合在一起對外提供服務,在本地maven基礎配置settings.xml中使用。

2.3倉庫拉取jar包流程

1)Maven可直接從【hosted宿主倉庫】下載構件,也可以從【proxy代理倉庫】下載構件,而代理倉庫間接的從所代理的【遠程倉庫】下載並緩存構件

2)爲了方便,Maven可以從倉庫組下載構件,而倉庫組並沒有實際的內容(下圖中用虛線表示,它會轉向包含的宿主倉庫或者代理倉庫獲得實際構件的內容).

2.4創建自己的倉庫

(~~非必要~~)直接使用Nexus預定義了2個本地倉庫maven-releases, maven-snapshots就行,用來存放我們自己工程發佈的jar包

根據類型選擇其中一個:

如果是創建的proxy倉庫或者hosted倉庫,需要添加到公共倉庫裏。

2.5上傳本地jar包

(~~非必要~~):直接通過工程deploy發佈我們自己工程項目

3.使用nexus

3.1 maven中配置nexus

1、目的:在本地maven中配置nexus私服,可以:

  • 在本地項目下載第三方jar包時優先去nexus私服中下載
  • 項目組其他maven項目發佈到nexus後,供其他人下載

2、方式:修改setting.xml文件,可以修改maven安裝目錄下conf中的該文件($MAVEN_HOME/conf/setting.xml),也可以修改用戶目錄下.m2目錄的該文件,我選擇修改後者,因爲更換maven版本時不需要考慮配置文件的再次修改。

1)設置私服賬號密碼:servers標籤增加如下內容

注意這裏配置的server的id必須和pom文件中的distributionManagement對應倉庫的id保持一致,maven在處理髮布時會根據id查找用戶名稱和密碼進行登錄和文件的上傳發布。

這裏的ID值對應pom.xml的id=releases的倉庫,也就是

    <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>

2)爲倉庫列表配置的下載鏡像列表<mirrors>標籤下增加下面內容

     <!--爲倉庫列表配置的下載鏡像列表。  -->
     <mirror>
		<!--該鏡像的唯一標識符。id用來區分不同的mirror元素。  -->
        <id>nexus-ma</id>
        <name>internal nexus repository</name>
        <!--鏡像採用配置好的組的地址-->
		<!--該鏡像的URL。構建系統會優先考慮使用該URL,而非使用默認的服務器URL。  -->
        <url>http://10.20.30.158:8081/repository/maven-public/</url>
		<!--此處配置所有的構建均從私有倉庫中下載 *代表所有,也可以寫central -->
        <mirrorOf>*</mirrorOf>
     </mirror>

3)配置遠程發佈的私服<profiles>標籤中增加下面內容

    <profile>
		<id>nexus-pr</id>
		<!--遠程倉庫列表,它是Maven用來填充構建系統本地倉庫所使用的一組遠程項目。  -->
		<repositories>
			<!--發佈版本倉庫-->
			<repository>
				<id>nexus-ma</id>
				<name>Nexus Central</name>
				<!--地址是nexus中repository(Releases/Snapshots)中對應的地址--
				<!-- 虛擬的URL形式,指向鏡像的URL-->
				<url>http://10.20.30.158: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://10.20.30.158:8081/repository/maven-public/</url>
				<layout>default</layout>
				<snapshots>
					<enabled>true</enabled>
				</snapshots>
				<releases>
					<enabled>true</enabled>
				</releases>
			</pluginRepository>
		</pluginRepositories>
	</profile>

4)激活 <profile>中的ID使之生效

  <activeProfiles>
     <!--需要激活 <profile>中的ID才生效-->  
    <activeProfile>nexus-pr</activeProfile>
  </activeProfiles>

3.2 項目中配置私服

1、目的

項目通過執行maven的deploy任務可以將release或者snapshot版本發佈到nexus上

2、方式

pom.xml中添加:

<distributionManagement>
        <repository>
            <!--id的名字可以任意取,但是在setting文件中的屬性<server>的ID與這裏一致-->
            <id>releases</id>
            <!--指向倉庫類型爲host(宿主倉庫)的儲存類型爲Release的倉庫-->
            <url>http://10.20.30.158:8081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>snapshots</id>
            <!--指向倉庫類型爲host(宿主倉庫)的儲存類型爲Snapshot的倉庫-->
            <url>http://10.20.30.158:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
</project>

其中maven-releases與maven-snapshots區別,是體現在創建倉庫時【version pollcy版本策略】屬性的設置上:

工程中通過pom.xml中version的內容(版本號中-SNAPSHOT部分)來決定deploy時發佈到哪個庫中

3.3 Maven deploy詳解

1、maven中的倉庫分爲兩種

  • snapshot快照倉庫:snapshot快照倉庫用於保存開發過程中的不穩定版本,
  • release發佈倉庫:release正式倉庫則是用來保存穩定的發行版本。

定義一個maven項目(project或者模塊)爲快照版本,只需要在pom文件中在該模塊的version版本號後加上-SNAPSHOT即可(注意這裏必須是大寫),如下:

<version>1.0-SNAPSHOT</version>

如果帶有“-SNAPSHOTS”  打包快照版本,否則即爲線上版本,約定俗成的命名,如下:

<version>1.0-RELEASE</version>

maven會根據模塊的版本號(pom文件中的version)中是否帶有-SNAPSHOT來判斷是快照版本還是正式版本。

  • 如果是快照版本,那麼在mvn deploy時會自動發佈到快照版本庫中,使用快照版本的模塊,在不更改版本號的情況下,直接編譯打包時,maven【會自動從鏡像服務器上下載最新的快照版本】
  • 如果是正式發佈版本,那麼在mvn deploy時會自動發佈到正式版本庫中,而使用正式版本的模塊,在不更改版本號的情況下,編譯打包時如果本地已經存在該版本的模塊則不會主動去鏡像服務器上下載

所以,最佳實踐:我們在開發階段,可以將公用庫的版本設置爲【快照版本】,而被依賴組件則引用快照版本進行開發,在公用庫的快照版本更新後,我們也不需要修改pom文件提示版本號來下載新的版本,直接mvn執行相關編譯、打包命令即可重新下載最新的快照庫了,從而也方便了我們進行開發。

 如果是快照版本,那麼在mvn deploy時會自動發佈到快照版本庫中,而使用快照版本的模塊,在不更改版本號的情況下,直接編譯打包時,maven會自動從鏡像服務器上下載最新的快照版本。

        SNAPSHOT是不穩定版,可能是還在開發中的版本,在開發時用戶A可能每天都會更新代碼,可能會頻繁的發佈版本。而另一組用戶B需要實時得到A的最新代碼版本,以進行同步開發。如果使用RELEASE倉庫需要不停的更換座標,才能升級到最新版本。而SNAPSHOT倉庫則不需要這樣做,用戶A和用戶B都不用升級版本。用戶A每次發佈時會根據當時時間創建一個新的快照版本,之前的快照版本也會保留成爲歷史版本。用戶B每次構建項目時會自動根據版本時間加載最新的JAR包,這種模式更加適合於多模塊同步開發測試階段

       如果是正式發佈版本,那麼在mvn deploy時會自動發佈到正式版本庫中,而使用正式版本的模塊,在不更改版本號的情況下,編譯打包時如果本地已經存在該版本的模塊則不會主動去鏡像服務器上下載。

      所以,我們在開發階段,可以將公用庫的版本設置爲快照版本,而被依賴組件則引用快照版本進行開發,在公用庫的快照版本更新後,我們也不需要修改pom文件提示版本號來下載新的版本,直接mvn執行相關編譯、打包命令即可重新下載最新的快照庫了,從而也方便了我們進行開發。

       用戶A將代碼打包發佈到RELEASE倉庫,具體操作參考上篇文章。用戶B使用時,需要在pom.xml添加JAR包的依賴座標。如果用戶A將版本從1.0升級爲2.0,用戶B使用時也需要同時在pom.xml中修改座標版本。但是RELEASE是穩定版本,是經過測試以後纔會發佈的,通常不會頻繁的升級版本

4.4 完整的pom.xml示例

<?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>
  -->
<localRepository>D:\06.tools\maven-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>
        <!--鏡像採用配置好的組的地址-->
        <url>http://10.20.30.158: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://10.20.30.158: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://10.20.30.158: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>

 

五、常見問題

1、登錄時,默認密碼提示超時處理方式

問題現象

Incorrect username or password, or no permission (Nexus3 登陸密碼不爲 admin123 、重置登陸密碼)

問題分析及處理

後來注意到在登陸時有提示信息 ,密碼保存在 /nexus-data下的 admin.password 中

找到admin.password ,查看並複製密碼登錄即可,然後登錄後會提示修改密碼:

注意密碼只有這一部分:cb424ffc-fc4b-41c1-9cbf-d7ea26efd978,緊跟後面的 bash-4.2$ 不是密碼內容

2、爲Nexus配置阿里雲代理倉庫

問題現象

Nexus默認遠程倉庫爲maven的中央倉庫,https://repo1.maven.org/maven2/,國內訪問慢導致下載很慢

問題分析及處理

方式1:直接修改nexus自帶的maven-centra代理庫url爲:http://maven.aliyun.com/nexus/content/groups/public

方式二:添加阿里雲代理倉庫將其加入maven-public並設置順序在maven-central代理庫前面

1)添加代理倉庫,create repository  ->  maven2 proxy

填寫:設置倉庫名稱,倉庫地址,倉庫存儲的位置(default就行)

name:nexus-aliyun

remote storage:http://maven.aliyun.com/nexus/content/groups/public

把nexus-aliyun添加到倉庫組中,記得把nexus-aliyun排在maven-central代理庫上邊。

這樣,就可以優先訪問阿里雲倉庫了。

六、參考

1)安裝配置運行
https://www.cnblogs.com/breeze-zZ/p/11049743.html

2)發佈項目到私服
https://www.cnblogs.com/lenovo_tiger_love/p/10309782.html

3)maven的pom.xml配置詳解(也有在linux安裝nexus過程)
https://blog.csdn.net/luoww1/article/details/87718932?utm_medium=distribute.pc_relevant.none-task-blog-baidujs-7

4)登錄時,默認密碼提示超時處理方式
https://cloud.tencent.com/developer/article/1478468

5)爲Nexus配置阿里雲代理倉庫
https://www.cnblogs.com/godwithus/p/8955824.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章