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

相关文章
相关标签/搜索