首页 > 代码库 > Nexus+Maven私仓

Nexus+Maven私仓

Nexus搭建maven私有库自动打包

maven 项目管理私服工具; Maven项目对象模型(POM);

apache-maven-3.3.9-bin.tar.gz

nexus-2.14.2-01-bundle.tar.gz


1、java 环境变量

/etc/profile

export JAVA_HOME=/usr/local/java

export PATH=$JAVA_HOME/bin:$PATH

export CLASSPATH=.:$java_home/lib/dt.jar:$JAVA_HOME/lib/tools.jar


2、maven 环境变量

/etc/profile

export MAVEN_HOME=/vdb/maven

export MAVEN=$MAVEN_HOME/bin

export PATH=$MAVEN:$PATH


3、版本验证;

# mvn -version


5、配置示例:

[root@test]# cat conf/nexus.properties |grep -v ^# |grep -v ^$

application-port=8081

application-host=0.0.0.0

nexus-webapp=${bundleBasedir}/nexus

nexus-webapp-context-path=/nexus

nexus-work=${bundleBasedir}/../sonatype-work/nexus

runtime=${bundleBasedir}/nexus/WEB-INF

storage.diskCache.bufferSize=4096


6、启动进程

进入bin目录运行nexus;

cd nexus/bin

启动

./nexus start

关闭

./nexus stop


URL 访问:

http://10.207.101.100:8081/nexus/index.html 

默认账户:admin 

默认密码:admin123


1、将所有type为proxy的configuration配置选项中DownloadRemoteIndex置为True,然后点击Save保存

其中3rd party选项中可以上传第三方jar包一些maven下载不下来的,公共仓库上找不到的,就可以在3rd party中的Artifacts upload选项卡中上传jar包;


2、新建组  将右边的Available Repositories全部拖到左边点击Save保存 

3、最后右键项目->Run As->Run Configurations双击左边选项卡的Maven Build新建一个


仓库地址/名称

3rd party 第三方的包

http://10.207.101.100:8081/nexus/content/repositories/thirdparty/


Central 中心仓

http://10.207.101.100:8081/nexus/content/repositories/central/


Releases   东财内部包发布仓

http://10.207.101.100:8081/nexus/content/repositories/releases/

 


POM引入东财数据中心发布仓

······

<repositories>

    <repository>

        <id>dc-releases</id>

        <name>dc releases</name>

        <url>http://10.207.101.100:8081/nexus/content/repositories/releases/</url>

    </repository>

    <repository>

        <id>dc-central</id>

        <name>dc central</name>

        <url>http://10.207.101.100:8081/nexus/content/repositories/central/</url>

    </repository>

    <repository>

        <id>dc-thirdparty</id>

        <name>dc thirdparty</name>

        <url>http://10.207.101.100:8081/nexus/content/repositories/thirdparty/</url>

    </repository>

</repositories>

······


引入依赖jar包

······

<dependency>

    <groupId>com.eastmoney.datacenter</groupId>

    <artifactId>eastmoney-dc-utils</artifactId>

    <version>1.0.0</version>

</dependency>

 ····

<dependency>

    <groupId>com.eastmoney.datacenter</groupId>

    <artifactId>eastmoney-dc-elasticsearch</artifactId>

    <version>1.0.0</version>

</dependency>

·····


需要注意的是,当pom.xml中同时配置了releases仓库和snapshots仓库时;

pom.xml文件开头的版本配置<version>1.0.0-SNAPSHOT</version>为build到snapshots库,

而<version>1.0.0</version>**不带-SNAPSHOT的会build到releases库,

如果只配置了releases库而版本号写的是带-SNAPSHOT的,build到最后一步会报400错误。


本文出自 “logs” 博客,请务必保留此出处http://51log.blog.51cto.com/6076767/1918414

Nexus+Maven私仓