1、在Nexus的bin目录下shift+右键-打开命令窗口,输入nexus /run (或者使用nexus /start)开启nexus服务

(直接打开nexus.exe无法启动)

使用Nexus(3.7.1)建立Maven仓库私服

服务启动完成后效果如下

使用Nexus(3.7.1)建立Maven仓库私服

2、登录nuxes服务器,默认地址和端口为http://localhost:8081/

使用Nexus(3.7.1)建立Maven仓库私服

点击sign in 登录。默认的用户名和密码为admin/ admin123

点击配置图标(齿轮),点击Repositories可以以查看当前的仓库配置,我们这里使用默认配置。

使用Nexus(3.7.1)建立Maven仓库私服

 

3、配置maven的settting.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">

<localRepository>F:\maven\repository</localRepository>

<pluginGroups></pluginGroups>
<proxies></proxies>

<!--server中添加nexus的用户名和密码-->
<servers>
    <server>
      <id>nexus</id>
      <username>admin</username>
      <password>admin123</password>
    </server>

  </servers>

<!--mirror中添加nexus的访问路径-->
<mirrors>
     <mirror>
      <id>nexus</id>
      <mirrorOf>*</mirrorOf>
      <url>
http://localhost:8081/repository/maven-public/</url>
    </mirror>

</mirrors>

<!--profile中添加nexus的两个仓库设置-->
  <profiles>
   <profile>
      <id>nexus</id>
      <repositories>
        <repository>
          <id>maven-public</id>
          <url>
http://localhost:8081/repository/maven-public/</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </repository>
      </repositories>
     <pluginRepositories>
        <pluginRepository>
          <id>maven-public</id>
          <url>
http://localhost:8081/repository/maven-public/</url>
          <releases><enabled>true</enabled></releases>
          <snapshots><enabled>true</enabled></snapshots>
        </pluginRepository>
      </pluginRepositories>
    </profile>

  </profiles>

<!--是能nexus的profile-->
<activeProfiles>
    <activeProfile>nexus</activeProfile>
  </activeProfiles>

</settings>

 

4、设置maven项目的pom.xml文件

在添加

<distributionManagement>
  <repository>
    <id>nexus</id>
    <name>Releases</name>
    <url>http://localhost:8081/repository/maven-releases</url>
  </repository>
  <snapshotRepository>
    <id>nexus</id>
    <name>Snapshot</name>
    <url>http://localhost:8081/repository/maven-snapshots</url>
  </snapshotRepository>
</distributionManagement>

使用Nexus(3.7.1)建立Maven仓库私服

5、下载的jar默认保存路径为nexus-3.7.1-02-win64\nexus-3.7.1-02\system,完成以上步骤后可以通过这里查看是否已下载jar包,或者在web界面查看

使用Nexus(3.7.1)建立Maven仓库私服

相关文章:

  • 2021-06-04
  • 2022-12-23
  • 2022-12-23
  • 2021-12-28
  • 2021-10-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-02-07
  • 2021-08-19
  • 2022-12-23
  • 2021-09-13
  • 2021-07-03
相关资源
相似解决方案