1. 程式人生 > >Centos7下按照配置nexus2

Centos7下按照配置nexus2

Oz IE 下載到本地 mes show ... www. tor home

一、什麽是Nexus

技術分享圖片

二、安裝並配置Nexus

[root@linux-node1 ~]# http://www.sonatype.com/download-oss-sonatype
[root@linux-node1 ~]# tar -xf nexus-2.13.0-01-bundle.tar.gz
[root@linux-node1 ~]# cd nexus-2.13.0-01/bin
[root@linux-node1 ~]# mv nexus-2.13.0-01 /usr/local/
[root@linux-node1 ~]# cd /usr/local/
[root@linux-node1 local]# ls
apache-maven-3.3.9             bin  games    lib    libexec  nexus-2.13.0-01  sbin   src
apache-maven-3.3.9-bin.tar.gz  etc  include  lib64  maven    nodejs           share
[root@linux-node1 local]# ln -s nexus-2.13.0-01 nexus
[root@linux-node1 local]# cd /usr/local/nexus
[root@linux-node1 nexus]# ls
bin  conf  lib  LICENSE.txt  logs  nexus  NOTICE.txt  tmp
[root@linux-node1 nexus]# cp bin/nexus /etc/init.d/
[root@linux-node1 nexus]# chmod 755 /etc/init.d/nexus 
[root@linux-node1 nexus]# chown root /etc/init.d/nexus 、
[root@linux-node1 nexus]# vim /etc/init.d/nexus
NEXUS_HOME="/usr/local/nexus"
RUN_AS_USER=root
[root@linux-node1 init.d]# cd /etc/init.d/
[root@linux-node1 init.d]# chkconfig --add nexus
[root@linux-node1 init.d]# chkconfig --levels 345 nexus on
[root@linux-node1 init.d]# service nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Starting Nexus OSS...
Started Nexus OSS.

三、登錄Nexus界面

登錄界面:http://{ip}:8081/nexus/
默認用戶名密碼 admin admin123

四、Nexus的流程

Nexus MAVEN的私有倉庫
如果沒有nexus 項目的打包都需要通過公網下載
不利於包的管理和共用
如果沒有私服,我們所需的所有構件都需要通過maven的中央倉庫和第三方的Maven倉庫下載到本地,而一個團隊中的所有人都重復的從maven倉庫下載構件
技術分享圖片
部署工作流:
技術分享圖片

五、Apache Maven

Apache Maven
To use Nexus Repository Manager Pro and Nexus Repository Manager OSS with Apache Maven, configure Maven to check the repository manager instead of the default, built-in connection to the Central Repository.

To do this, you add a mirror configuration and override the default configuration for the central repository in your ~/.m2/settings.xml as shown:

<settings>
  <mirrors>
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://localhost:8081/nexus/content/groups/public</url>
    </mirror>
  </mirrors>
  <profiles>
    <profile>
      <id>nexus</id>
      <!--Enable snapshots for the built in central repo to direct -->
      <!--all requests to nexus via the mirror -->
      <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>
    <!--make the profile active all the time -->
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
</settings>

六、參考資料:

  • maven結合Nexus:
    https://help.sonatype.com/repomanager2/maven-and-other-build-tools/jenkins
  • Jenkins中選擇Nexus插件:
    https://help.sonatype.com/repomanager2/maven-and-other-build-tools/jenkins

Centos7下按照配置nexus2