Nexus3.6安装、setting配置和jar包deploy

简介: Nexus3.6安装、setting配置和jar包deploy


Nexus 是Maven仓库管理器,如果你使用Maven,你可以从Maven中央仓库 下载所需要的构件(artifact),但这通常不是一个好的做法,在本地架设一个Maven仓库服务器,在代理远程仓库的同时维护本地仓库,以节省带宽和时间,Nexus就可以满足这样的需要。

此外,他还提供了强大的仓库管理功能,构件搜索功能,它基于REST,友好的UI是一个extjs的REST客户端,它占用较少的内存,基于简单文件系统而非数据库。

还有,搭建团队Nexus (私服),方便于我们自定义的jar和war存档管理,可以避免了团队使用的工具包不一致的问题。


1.下载

http://www.sonatype.com/download-oss-sonatype


2.安装/卸载(install\uninstall)【本文以Windows环境为例】

cmd进入到解压目录:E:\nexus3.6\nexus-3.6.1-02-win64\nexus-3.6.1-02\bin


  1. E:\nexus3.6\nexus-3.6.1-02-win64\nexus-3.6.1-02\bin>nexus.exe /install
  2. Installed service 'nexus'.

 

3.启动服务

cmd窗口:输入services.msc 找到nexus服务,点击启动


4.访问端口配置

  1. 进入E:\nexus3.6\nexus-3.6.1-02-win64\nexus-3.6.1-02\etc目录,打开nexus-default.properties文件
  2. ,找到application-port=9090,修改成你自己的端口
## 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

 

5.启动/停止nexus

  1. cmd窗口-> net start nexus(启动服务)
  2. net stop nexus(停止服务)


6.访问地址

  • http://ip:端口/
  • 默认账号密码:admin/admin123


7.访问地仓库类型

  1. hosted 宿主仓库:主要用于部署无法从公共仓库获取的构件(如 oracle JDBC 驱动)以及自己或第三方的项目构件;
  2. proxy 代理仓库:代理公共的远程仓库;
  3. group 仓库组Nexus 通过仓库组的概念统一管理多个仓库,这样我们在项目中直接请求仓库组即可请求到仓库组管理的多个仓库。

 

 图片.png

访问地仓库类型


8.配置私服(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">
    <!--设置的maven本地仓库-->
    <localRepository>D:\Java\Maven\m2\repository</localRepository>
    <pluginGroups/>
    <proxies/>
    <!--配置服务端的一些设置。一些设置如安全证书不应该和pom.xml一起分发。这种类型的信息应该存在于构建服务器上的settings.xml文件中。 -->
    <servers>
        <server>
            <!--这是server的id(注意不是用户登陆的id),该id与distributionManagement中repository元素的id相匹配。 -->
            <id>nexus</id>
            <!--nexus中配置的用户名密码-->
            <username>admin</username>
            <password>admin123</password>
        </server>
        <!--将项目发布到私服中需要用到-->
        <server>
            <!--这是server的id(注意不是用户登陆的id),该id与distributionManagement中repository元素的id相匹配。 -->
            <id>newcapec-zhifu-releases</id>
            <!--nexus中配置的用户名密码-->
            <username>admin</username>
            <password>admin123</password>
        </server>
        <!--将项目发布到私服中需要用到-->
        <server>
            <!--这是server的id(注意不是用户登陆的id),该id与distributionManagement中repository元素的id相匹配。 -->
            <id>newcapec-zhifu-snapshots</id>
            <!--nexus中配置的用户名密码-->
            <username>admin</username>
            <password>admin123</password>
        </server>
    </servers>
    <!--为仓库列表配置的下载镜像列表。  -->
    <mirrors>
        <mirror>
            <!--该镜像的唯一标识符。id用来区分不同的mirror元素。  -->
            <id>nexus</id>
            <!--此处配置所有的构建均从私有仓库中下载 *代表所有,也可以写central -->
            <mirrorOf>*</mirrorOf>
            <name>central repository</name>
            <!--该镜像的URL。构建系统会优先考虑使用该URL,而非使用默认的服务器URL。  -->
            <url>http://192.168.112.61:8081/repository/maven-public/</url>
        </mirror>
    </mirrors>
    <!--根据环境参数来调整构建配置的列表。settings.xml中的profile元素是pom.xml中profile元素的裁剪版本。-->
    <!--它包含了id,activation, repositories, pluginRepositories和 properties元素。-->
    <!--这里的profile元素只包含这五个子元素是因为这里只关心构建系统这个整体(这正是settings.xml文件的角色定位),而非单独的项目对象模型设置。-->
    <!--如果一个settings中的profile被激活,它的值会覆盖任何其它定义在POM中或者profile.xml中的带有相同id的profile。  -->
    <profiles>
        <profile>
            <id>nexus</id>
            <!--远程仓库列表,它是Maven用来填充构建系统本地仓库所使用的一组远程项目。  -->
            <repositories>
                <!--发布版本仓库-->
                <repository>
                    <id>nexus</id>
                    <!--name随便-->
                    <name>Nexus Release Snapshot Repository</name>
                    <!--地址是nexus中repository(Releases/Snapshots)中对应的地址-->
                    <url>http://192.168.112.61:8081/repository/maven-releases/</url>
                <!--true或者false表示该仓库是否为下载某种类型构件(发布版,快照版)开启。 -->
                <releases>
                    <enabled>true</enabled>
                </releases>
                <snapshots>
                    <enabled>true</enabled>
                </snapshots>
            </repository>
            </repositories>
            <!--发现插件的远程仓库列表。仓库是两种主要构件的家。第一种构件被用作其它构件的依赖。这是中央仓库中存储的大部分构件类型。另外一种构件类型是插件。-->
            <!--各节点的含义和repository是一样的-->
            <pluginRepositories>
                <pluginRepository>
                    <id>nexus</id>
                    <name>Nexus Release Snapshot Repository</name>
                    <url>http://192.168.112.61:8081/repository/maven-releases/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
        <!--设置maven编译器级别-->
        <profile>
            <id>jdk18</id>
            <activation>
                <!--profile默认是否激活的标识 -->
                <activeByDefault>true</activeByDefault>
                <!--activation有一个内建的java版本检测,如果检测到jdk版本与期待的一样,profile被激活。 -->
                <jdk>1.8</jdk>
            </activation>
            <properties>
                <maven.compiler.source>1.8</maven.compiler.source>
                <maven.compiler.target>1.8</maven.compiler.target>
                <maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
            </properties>
        </profile>
    </profiles>
    <!--激活配置-->
    <activeProfiles>
        <!--profile下的id-->
        <activeProfile>nexus</activeProfile>
    </activeProfiles>
</settings>


9.上传jar包到Nexus

9.1 pom方式:

  1. pom.xml中添加,和dependencies属于同一级别,在project级别下
<!--将项目发布到私服中-->
<distributionManagement>
 <repository>
    <id>newcapec-zhifu-releases</id>
    <name>newcapec-zhifu-releases</name>
    <url>http://192.168.112.61:8081/repository/newcapec-zhifu-releases/</url>
 </repository>
 <snapshotRepository>
    <id>newcapec-zhifu-snapshots</id>
    <name>newcapec-zhifu-snapshots</name>
    <url>http://192.168.112.61:8081/repository/newcapec-zhifu-snapshots/</url>
 </snapshotRepository>
</distributionManagement>
  1.  
  2. id为要上传的repository的唯一标示,url为要上传的repository的路径
  3. mvn deploy即可

图片.png

打包上传进度

 

图片.png上传成功后-私服显示

 

9.2 命令方式:

  1. mvn deploy:deploy-file -DgroupId=xxx.xxx -DartifactId=xxx -Dversion=0.0.2 -Dpackaging=jar
  2. -Dfile=D:\xxx.jar -Durl=http://xxx.xxx.xxx.xxx:8081/repository/3rdParty/ -DrepositoryId=3rdParty
  1. 其中-DgroupId 为上传的jargroupId
  2. -DartifactId 为上传的jarartifactId
  3. -Dversion 为上传的jar的需要被依赖的时候的版本号
  4. 然后是-Dpackagingjar,-Dfilejar包路径
  5. -Durl 为要上传的路径,可以通过以下方式获取到
  6. -DrepositoryId repository的唯一标示,跟第二步中赋权配置的server相同


9.3 页面上传(Upload):

Nexus3.9版本支持界面上传(Nexus2.x的版本也支持)

 

参考来源:http://blog.csdn.net/iopfan/article/details/71107686


目录
相关文章
|
1月前
|
Java Docker 容器
|
1月前
|
运维 Java Shell
Linux非常详细的shell运维脚本一键启动停止状态SpringBoot打成可运行jar包
Linux非常详细的shell运维脚本一键启动停止状态SpringBoot打成可运行jar包
32 0
|
2月前
|
Java Maven 微服务
springboot项目开启远程调试-jar包
springboot项目开启远程调试-jar包
25 0
|
1天前
|
前端开发 Java Linux
宝塔Linux:部署His医疗项目通过jar包的方式
宝塔Linux:部署His医疗项目通过jar包的方式
|
7天前
|
Java
如何解决使用若依前后端分离打包部署到服务器上后主包无法找到从包中的文件的问题?如何在 Java 代码中访问 jar 包中的资源文件?
如何解决使用若依前后端分离打包部署到服务器上后主包无法找到从包中的文件的问题?如何在 Java 代码中访问 jar 包中的资源文件?
40 0
|
9天前
|
Java Maven
springboot jar包启动提示没有主清单属性
springboot jar包启动提示没有主清单属性
|
10天前
|
分布式计算 DataWorks Java
DataWorks产品使用合集之阿里云DataWorks专有云环境下,上传MaxCompute的UDF(用户自定义函数)的JAR包的步骤如何解决
DataWorks作为一站式的数据开发与治理平台,提供了从数据采集、清洗、开发、调度、服务化、质量监控到安全管理的全套解决方案,帮助企业构建高效、规范、安全的大数据处理体系。以下是对DataWorks产品使用合集的概述,涵盖数据处理的各个环节。
20 0
|
20天前
|
Java
JSTL jar包版本错误attribute items does not accept any expressions
确保你在 `items` 属性中使用了一个实际的集合或数组变量,而不是表达式,以解决这个问题。
12 0
|
1月前
|
Java Android开发
读取jar包内外文件
读取jar包内外文件