maven私庫nexus3安裝及使用

1、試驗環境

一、操做系統:Windows 10 
二、nexus版本:nexus-3.0.1-01-win64apache

2、安裝

一、下載地址:http://www.sonatype.com/download-oss-sonatype 
下載 
二、咱們下載nexus-3.0.1-01-win64.exe後雙擊安裝便可,安裝完成後默認開放8081端口。eclipse

3、使用

安裝成功後有兩個默認帳號admin、anonymous,其中admin具備所有權限默認密碼admin123;anonymous做爲匿名用戶,只具備查看權限。 
倉庫 
用戶 
倉庫maven

pepositories說明ui

maven-central:maven中央庫,默認從https://repo1.maven.org/maven2/拉取jar 
maven-releases:私庫發行版jar 
maven-snapshots:私庫快照(調試版本)jar 
maven-public:倉庫分組,把上面三個倉庫組合在一塊兒對外提供服務,在本地maven基礎配置settings.xml中使用。this

倉庫 
component

本地maven庫配置settings.xmlurl

<settings>

  <pluginGroups>
    <pluginGroup>org.sonatype.plugins</pluginGroup>
  </pluginGroups>

 <servers>
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
  </servers>

<mirrors>
    <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/repository/maven-public/</url>
    </mirror>
    <mirror>  
      <id>repo2</id>  
      <mirrorOf>central</mirrorOf>  
      <name>Human Readable Name for this Mirror.</name>  
      <url>http://repo2.maven.org/maven2/</url>  
    </mirror>

  </mirrors>

<profiles>
<profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://central</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>

  </profiles>
  <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </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

工程配置pox.xmlspa

<distributionManagement>
  <repository>
      <id>nexus</id>
      <name>Releases</name>
      <url>http://localhost:8081/repository/maven-releases</url>
    </repository>
    <snapshotRepository>
      <id>nexus</id>
      <name>Snapshot</name>
      <url>http://localhost:8081/repository/maven-snapshots</url>
    </snapshotRepository>
  </distributionManagement>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
<build>
    <defaultGoal>compile</defaultGoal>
    <finalName>page</finalName>
    <plugins>
        <plugin> 
            <groupId>org.apache.maven.plugins</groupId> 
            <artifactId>maven-surefire-plugin</artifactId>  
            <configuration>  
                <skip>true</skip>  
            </configuration> 
        </plugin>
        <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.3</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>
    </plugins>
  </build>
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

編譯到maven私庫操作系統

deploy -e 
項目右單擊->Run As->Maven build.. 
進入以下界面 
eclipse3d

快照編譯:pom.xml中版本設置調試

<version>0.0.1-SNAPSHOT</version>
  • 1

編譯後在nexus中看到以下圖結果,快照已經編譯到nexus中Components-> maven-snapshots。 
快照

發行版編譯:pom.xml中版本設置

<version>0.0.1-RELEASE</version>
  • 1

編譯後在nexus中看到以下圖結果,發行版已經編譯到nexus中Components->maven-releases。 
發行版

相關文章
相關標籤/搜索