maven倉庫Nexus

Maven環境html

tar -xvf jdk-8u151-linux-x64.tar.gz -C /usr/local
 cd /usr/local/
 mv jdk1.8.0_151   jdk
 vim /etc/profile
JAVA_HOME=/usr/local/jdk
export PATH=$JAVA_HOME/bin:$PATH
source  /etc/profile
tar  -xvf apache-maven-3.6.1-bin.tar.gz -C /usr/local/
mv /usr/local/apache-maven-3.6.1/ /usr/local/maven
vim /etc/profile
export MAVEN_HOME=/usr/local/maven
export MAVEN_HOME=$MAVEN_HOME/bin
PATH=$MAVEN_HOME:$PATH:$HOME/bin:/usr/local/git/bin
source  /etc/profile

nexus:java

wget https://download.sonatype.com/nexus/3/latest-unix.tar.gz
tar -xvf nexus-3.16.1-02-unix.tar.gz -C /usr/local/
ln -s /usr/local/nexus-3.16.1-02 /usr/local/nexus

配置(可選):linux

vim /usr/local/nexus/bin/nexus.rc  #這裏是控制啓動用戶的
#run_as_user=""   #默認是root用戶啓動,固然你能夠去掉註釋如:run_as_user="nexus"就變成nexus用戶啓動了
vim /usr/local/nexus/bin/nexus.vmoptions   #這個文件有一些啓動參數,這裏修改佔用內存,存儲,日誌的位置等
-Xms1200M
-Xmx1200M
-XX:MaxDirectMemorySize=2G
-XX:+UnlockDiagnosticVMOptions
-XX:+UnsyncloadClass
-XX:+LogVMOutput
-XX:LogFile=../sonatype-work/nexus3/log/jvm.log
-XX:-OmitStackTraceInFastThrow
-Djava.net.preferIPv4Stack=true
-Dkaraf.home=.
-Dkaraf.base=.
-Dkaraf.etc=etc/karaf
-Djava.util.logging.config.file=etc/karaf/java.util.logging.properties
-Dkaraf.data=../sonatype-work/nexus3  
-Djava.io.tmpdir=../sonatype-work/nexus3/tmp
-Dkaraf.startLocalConsole=false
vim /usr/local/nexus/etc/nexus-default.properties   #修改端口啊監聽地址在這個配置文件中
## DO NOT EDIT - CUSTOMIZATIONS BELONG IN $data-dir/etc/nexus.properties
##
# Jetty section
application-port=8081
application-host=0.0.0.0
nexus-args=${jetty.etc}/jetty.xml,${jetty.etc}/jetty-http.xml,${jetty.etc}/jetty-requestlog.xml
nexus-context-path=/

# Nexus section
nexus-edition=nexus-pro-edition
nexus-features=\
 nexus-pro-feature
vim /usr/local/nexus/bin/nexus   #修改jdk位置什麼的在這個啓動文件
INSTALL4J_JAVA_HOME_OVERRIDE=/usr/java/jdk   #默認這裏是#INSTALL4J_JAVA_HOME_OVERRIDE=  可是若是提示找不到jdk能夠修改這裏

設置開機啓動:git

vim /usr/lib/systemd/system/nexus.service
[Unit]                                                 
Description=nexus service

[Service]
Type=forking
LimitNOFILE=65536 
ExecStart=/usr/local/nexus/bin/nexus start
ExecReload=/usr/local/nexus/bin/nexus restart
ExecStop=/usr/local/nexus/bin/nexus stop
Restart=on-failure

[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl enable nexus
systemctl start nexus
systemctl status nexus

默認端口訪問:8081
#點擊右上角的Sign in就能夠登錄了,默認管理員用戶是admin,密碼是admin123github

管理界面

maven倉庫Nexus

admin:該用戶擁有Nexus的所有權限,默認密碼爲admin123。
#deployment:該用戶可以訪問Nexus,瀏覽倉庫內容、搜索、上傳部署構件,可是不能對Nexus進行任何配置,默認密碼爲deployment123。 #這個用戶顯示在新版裏面已經沒有了
anonymous:該用戶對應了全部未登陸的匿名用戶,它們能夠瀏覽倉庫並進行搜索。

maven倉庫Nexus
能夠禁止匿名用戶訪問apache

倉庫介紹
maven倉庫Nexusvim

1.component name的一些說明: 
    1)maven-central:maven中央庫,默認從https://repo1.maven.org/maven2/拉取jar 
    2)maven-releases:私庫發行版jar 
    3)maven-snapshots:私庫快照(調試版本)jar 
    4)maven-public:倉庫分組,把上面三個倉庫組合在一塊兒對外提供服務,在本地maven基礎配置settings.xml中使用。
2.Nexus默認的倉庫類型有如下四種:
    1)group(倉庫組類型):又叫組倉庫,用於方便開發人員本身設定的倉庫;
    2)hosted(宿主類型):內部項目的發佈倉庫(內部開發人員,發佈上去存放的倉庫);
    3)proxy(代理類型):從遠程中央倉庫中尋找數據的倉庫(能夠點擊對應的倉庫的Configuration頁簽下Remote Storage Location屬性的值即被代理的遠程倉庫的路徑);
    4)virtual(虛擬類型):虛擬倉庫(這個基本用不到,重點關注上面三個倉庫的使用);
3.Policy(策略):表示該倉庫爲發佈(Release)版本倉庫仍是快照(Snapshot)版本倉庫;
4.Public Repositories下的倉庫 
   1)3rd party: 沒法從公共倉庫得到的第三方發佈版本的構件倉庫,即第三方依賴的倉庫,這個數據一般是由內部人員自行下載以後發佈上去;
   2)Apache Snapshots: 用了代理ApacheMaven倉庫快照版本的構件倉庫 
   3)Central: 用來代理maven中央倉庫中發佈版本構件的倉庫 
   4)Central M1 shadow: 用於提供中央倉庫中M1格式的發佈版本的構件鏡像倉庫 
   5)Codehaus Snapshots: 用來代理CodehausMaven 倉庫的快照版本構件的倉庫 
   6)Releases: 內部的模塊中release模塊的發佈倉庫,用來部署管理內部的發佈版本構件的宿主類型倉庫;release是發佈版本;
   7)Snapshots:發佈內部的SNAPSHOT模塊的倉庫,用來部署管理內部的快照版本構件的宿主類型倉庫;snapshots是快照版本,也就是不穩定版本
因此自定義構建的倉庫組代理倉庫的順序爲:Releases,Snapshots,3rd party,Central。也可使用oschina放到Central前面,下載包會更快。

增長新的代理源:
maven倉庫Nexus
maven倉庫Nexus
maven倉庫Nexus
經常使用代理:緩存

1. aliyun
http://maven.aliyun.com/nexus/content/groups/public
2. apache_snapshot
https://repository.apache.org/content/repositories/snapshots/
3. apache_release
https://repository.apache.org/content/repositories/releases/
4. atlassian
https://maven.atlassian.com/content/repositories/atlassian-public/
5. central.maven.org
http://central.maven.org/maven2/
6. datanucleus
http://www.datanucleus.org/downloads/maven2
7. maven-central (安裝後自帶,僅需設置Cache有效期便可)
https://repo1.maven.org/maven2/
8. nexus.axiomalaska.com
http://nexus.axiomalaska.com/nexus/content/repositories/public
9. oss.sonatype.org
https://oss.sonatype.org/content/repositories/snapshots
10.pentaho
https://public.nexus.pentaho.org/content/groups/omni/

注意:設置私用倉庫可重複發送:
maven倉庫Nexus
設置完庫須要加入組裏面maven-public:
maven倉庫Nexus
maven倉庫Nexus
調用 Repository
settings.xml文件中指定nexus倉庫地址app

<server>
    <id>8-releases</id>
    <username>admin</username>
    <password>admin123</password>
    </server>
    <server>
    <id>8-snapshots</id>
    <username>admin</username>
    <password>admin123</password>
    </server>
<profile>
        <id>nexus</id>
        <repositories>
           <repository>
              <id>8-releases</id>
              <name>8-releases</name>
              <url>http://129.211.48.199:8081/content/repositories/releases/</url>
           </repository>
           <repository>
              <id>8-snapshots</id>
              <name>8-snapshots</name>
              <url>http://129.211.48.199:8081/content/repositories/snapshots/</url>
              <snapshots>
                 <enabled>true</enabled>
                 <updatePolicy>always</updatePolicy>
              </snapshots>
           </repository>
        </repositories>
     </profile>
<activeProfiles>
     <activeProfile>nexus</activeProfile>
  </activeProfiles>

較完整的maven配置文件settings.xml文件jvm

# servers 內添加用戶/密碼, 以便以後能夠向releases/snapshots本地倉庫(工廠)push jar 包
    <server>
      <id>releases</id>
      <username>admin</username>
      <password>admin123</password>
    </server>
    <server>
      <id>snapshots</id>
      <username>admin</username>
      <password>admin123</password>
    </server>

# mirrors增長私庫
    <mirror>
      <!--This sends everything else to /public -->
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>http://129.211.48.199:8081/repository/maven-public/</url>
    </mirror>
        <mirror>
      <id>nexus2</id>
      <mirrorOf>snapshots</mirrorOf>
      <url>http://129.211.48.199:8081/repository/maven-public/</url>
    </mirror>
# 必定要配置爲 <mirrorOf>*</mirrorOf>,即讓全部的倉庫都先通過私庫,這樣能夠將遠程下載的包緩存到本地

    <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://129.211.48.199:8081/repository/maven-central/</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>

     <pluginRepositories>
        <pluginRepository>
          <id>central</id>
          <url>http://129.211.48.199:8081/repository/maven-central/</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>

    </profile>

    <activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>
   #以上定義 profile,最後activeProfile 激活定義的profile
     #在profile中容許 訪問releases/snapshots倉庫 (工廠)

Maven安裝目錄下的 /conf/settings.xml 起全局控制做用。
用戶目下的Maven配置文件,即:~/.m2/settings.xml 僅對當前用戶用效
#更多settings.xml配置鏈接:https://helpcdn.aliyun.com/document_detail/57890.html
#nexus配置介紹:https://blog.51cto.com/caiyuanji/2117120
#maven的setting.xml詳解:http://www.cnblogs.com/hwaggLee/p/4579418.html
#settings.xml源文件:https://github.com/apache/maven/blob/master/apache-maven/src/conf/settings.xml

相關文章
相關標籤/搜索