您的位置:首页 > 其它

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

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

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





服务启动完成后效果如下





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





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

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





 

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>
4000

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





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



内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: