Nexus使用

1 创建Blob Stores

clipboard.png

2 创建User

clipboard.png

3 创建代理仓库

clipboard.png

然后再public组里面将这个aliyun-proxy仓库加入,排在maven-central之前即可

clipboard.png

 4 创建Host仓库 策略是release

clipboard.png

 

5 创建Host仓库 策略是snapshots

clipboard.png

 

创建好之后我们再来Public设置下优先顺序,把刚才加的两个仓库放到aliyun-proxy前面

clipboard.png

创建完仓库预览

clipboard.png

6 配置本地maven settings.xml

提示:两种配置方法,一种是直接配置maven目录下的conf下的settings.xml文件,另外一种是复制该文件到用户目录下的.m2目录,两种方法配置效果是一样的,看个人喜好了,加载顺序是.m2下的settings.xml目录接着是maven config目录下的settings.xml,配置文件如下:

<?xml version="1.0" encoding="UTF-8"?>

<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">
          
  <pluginGroups>
  </pluginGroups>

  <proxies>    
  </proxies>

  <servers>
    <!--这里配置我们刚才创建的user用户所对应的releases-->
    <server>
        <id>releases</id>
        <username>user</username>
        <password>123456</password>
    </server>
    <!--这里配置我们刚才创建的user用户所对应的Snapshots-->
    <server>
        <id>Snapshots</id>
        <username>user</username>
        <password>123456</password>
    </server>
  </servers>
  <mirrors>
    <!-- <mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>*</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror> -->
    <!--这里配置我们线上的public仓库就好-->
    <mirror>
        <id>nexus</id>
        <mirrorOf>*</mirrorOf>
        <url>https://nexus.awbeci.com/repository/maven-public/</url>
    </mirror>
  </mirrors>
</settings>

7 配置要上传到nexus项目pom.xml文件 

<packaging>jar</packaging>
    <distributionManagement>
        <!--配置线上releases仓库地址,只要是正式版本都会上传到该地址(注意要和settings.xml文件里面的配置名称相同)-->
        <repository>
            <id>releases</id>
            <url>https://nexus.awbeci.com/repository/awbeci/</url>
        </repository>
        <!--配置线上Snapshots仓库地址,只要是快照版本都会上传到该地址(注意要和settings.xml文件里面的配置名称相同)-->
        <snapshotRepository>
            <id>Snapshots</id>
            <url>https://nexus.awbeci.com/repository/awbeci-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.6.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                    <encoding>UTF-8</encoding>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-deploy-plugin</artifactId>
                <version>2.8.2</version>
                <executions>
                    <execution>
                        <id>deploy</id>
                        <phase>deploy</phase>
                        <goals>
                            <goal>deploy</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

8 编辑并发布jar包

mvn clean && mvn deploy -DskipTests=true

执行完成后,我们到线上看看是否上传成功

clipboard.png

clipboard.png

 

总结

1)服务器内存刚开始配置是1CPU 1G 内存,nexus start运行之后报错,升级服务器为2G内存之后就没问题了

2)nexus 默认是8081端口,我们可以修改文件/usr/local/nexus/nexus-3.15.0-01/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

值得注意的是不能把端口直接改成80,这样你就不能启动nexus,所以我们是通过nginx 80端口代理8081端口了。

3)nexus 配置内存是在 /usr/local/nexus/nexus-3.15.0-01/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

 

4)最好自己创建nexus用户,不要使用root用户启动nexus否则会出现警告

WARNING: ************************************************************
WARNING: Detected execution as "root" user. This is NOT recommended! 
WARNING: ************************************************************
Starting nexus

 

5)启动nexus:

/usr/local/nexus/nexus-3.15.0-01/bin/nexus {start|stop|run|run-redirect|status|restart|force-reload}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值