建立maven私服

作者: nayli | 来源:发表于2019-01-25 13:35 被阅读169次

一、下载安装与配置

下载

到官网下载:https://www.sonatype.com/download-oss-sonatype

image.png

下载的是oss3.x版本的(当时最新版),


image.png

安装

1、先将下载后的zip文件解压到指定文件夹
2、直接双击exe文件会闪退,所以使用命令行,管理员方式运行cmd

image.png
安装:nexus.exe /install
卸载:nexus.exe /uninstall
启动:nexus.exe /start
停止:neuxs.exe /stop
3、(可做可不做)为了方便使用将bin弄成系统环境变量
4、安装并启动完成后 直接访问http://localhost:8081/(是默认端口) 默认用户:admin 密码:admin123
5、如果要修改端口,就修改配置文件中的 nexus-3.14.0-04\etc\nexus-default.properties 的 application-port
## 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

配置用户

1、自改密码,进入用户账户,change password-->修改为其他密码就行了(1QsAZD0SV)
2、有其他问题直接上官网看文档


二、使用方式

上传jar包(三种方式)

1、如果是使用界面的update比较简单
2、使用配置方式 在maven的setting.xml文件中配置,要分清是自己下载的maven或者是idea的maven

<!-- 把jar包发布到私服中 -->
 <!--   配置服务器--><server> 
    <id>maven-public</id> 
    <username>admin</username> 
    <password>1QsAZD0SV</password> </server> <server> 
    <id>maven-releases</id> 
    <username>admin</username> 
    <password>1QsAZD0SV</password> </server> <server> 
    <id>maven-snapshots</id> 
    <username>admin</username> 
    <password>1QsAZD0SV</password> </server> 

项目的pom文件

<distributionManagement>
        <repository>
            <id>maven-releases</id>
            <name>Nexus Release Repository</name>
            <url>http://localhost:8081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>maven-snapshots</id>
            <name>Nexus Snapshot Repository</name>
            <url>http://localhost:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
</distributionManagement>

点击idea中deploy命令即可成功 mvn clean deploy 2.1.3 也可以使用命令行将下载的jar发布到私服

mvn deploy:deploy-file -DgroupId=com.weepal.wp-common 
-DartifactId=wp-common -Dversion=1.3.0 -Dpackaging=jar 
-DrepositoryId=nexus -Dfile=E:\Document\wp-common-1.3.0-RELEASE.jar-Durl=http://localhost:8081/repository/maven-release/

com.weepal.wp-common为pom中的groupId中的内容;
wp-common为pom中的artifactId中的内容;
1.3.0为pom中的version中的内容; 同时在maven中要添加权限

<server>
      <id>nexus</id>
      <username>admin</username>
      <password>1QsAZD0SV</password>
     </server>
 <repository>
    <id>nexus</id>
    <url>http://localhost:8081/repository/maven-release/</url>
    <releases>
     <enabled>true</enabled>
    </releases>
    <snapshots>
     <enabled>true</enabled>
    </snapshots>
 </repository>

从私服下载jar包

1、在pom文件中配置

<!-- 假如没有私服 ,则 本地仓库找不到,则访问中心仓库
     假如有私服 :访问顺序
       首先访问本地仓库
   本地仓库没有,则访问私服仓库
   私服仓库也没有,则访问中心仓库
 -->
     <!--下载jar配置开始-->
    <repositories>
        <repository>
            <id>alimaven</id>
            <name>aliyun maven</name>
            <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
        </repository>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>https://repo.spring.io/libs-milestone</url>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
        <repository>
            <id>nexus</id>
            <name>Nexus Repository</name>
            <url>http://localhoot:8081/repository/maven-public/</url>
        </repository>
    </repositories>
    <pluginRepositories>
        <pluginRepository>
            <id>nexus</id>
            <name>Nexus Plugin Repository</name>
            <url>http://localhoot:8081/repository/maven-public/</url>
        </pluginRepository>
    </pluginRepositories>
    <!--下载jar包配置结束-->

相关文章

  • 建立maven私服

    一、下载安装与配置 下载 到官网下载:https://www.sonatype.com/download-oss-...

  • maven---9使用Nexus创建私服

    首先私服是一种衍生出来的特殊的Maven远程仓库,构建私服的好处请看3.5私服 可以帮助大家建立私服的仓库管理软件...

  • Maven私服搭建

    什么是maven私服? 工程中如何使用? 如何接入maven私服? 了解maven私服 分为本地和远程 远程包括:...

  • maven私服

    1、配置本地maven settings.xml 使用私服 2、发布jar到私服配置本地maven setting...

  • Ubuntu server下搭建Maven私服Nexus

    Ubuntu server下搭建Maven私服Nexus Maven私服Nexus的作用,主要是为了节省资源,在内...

  • maven私服管理

    maven工程使用私服中需要添加repository 私服会有密码,所以需要在maven的settings文件中加...

  • 【maven】私服jar包引用和上传

    背景:昨天同事让我帮忙往私服里上传jar包,方便大家一起使用,特此研究maven私服相关。 maven私服简介 m...

  • Maven(5)Nexus

    前言 Maven是Java项目管理的利器,使用私服来管理Maven仓库是Maven使用的一条最佳实践。私服是内网的...

  • Nexus私服

    容器运行 默认账号admin admin123 配置PyPi私服 配置npm私服 配置 maven私服

  • Maven私服Nexus的搭建

    Maven私服Nexus的搭建 私服存在的合理性 Maven中的依赖是从服务器仓库中下载的,Maven的仓库只有两...

网友评论

    本文标题:建立maven私服

    本文链接:https://www.haomeiwen.com/subject/cctvdqtx.html