nexus2 私有仓库配置 maven私服配置

1.更新私有仓库的索引

 在nexus管理控制台

Repositories--Central--Configuration

Download Remote Indexes 选True

他就会自动下载索引

下载需要一会时间。

查看正在进行的任务

Administration--Scheduled Tasks

显示正在运行的任务,如正在下载索引

索引文件保存目录

D:\Program Files\nexus-2.7.0-06-bundle\sonatype-work\nexus\indexer\central-ctx

此文件下的文件可手工备份,还原。

验证

Browse Index下有好多目录

依次展开目录,选择jar文件,右侧会显示引入依赖的配置方法,如:

<dependency>
  <groupId>abbot</groupId>
  <artifactId>abbot</artifactId>
  <version>0.12.3</version>
</dependency>

 就不用再去公网上找了。

nexus3.x的url是

<url>http://localhost:8081/repository/maven-public/</url>

 2.设置镜像 settings.xml

配置 D:\Program Files\apache-maven-3.0.5\conf\settings.xml

加入mirror

<mirrors>
   <mirror>
      <id>centralMirror</id>
      <mirrorOf>*</mirrorOf>
      <name>centralMirror</name>
      <url>http://192.168.1.122:8081/nexus/content/groups/public/</url>
    </mirror>
</mirrors>

mirrorOf为*代表所有id的仓库,都使用此镜像,

还可以配置为central,nexus等,多个以逗号分隔

url为nexus中的仓库地址(局域网)

3.通过profile配置仓库 settings.xml

配置profile,开启snapshots包的依赖

  <profiles>
    <profile>
      <id>nexus-central</id>
      <repositories>
        <repository>
          <id>central</id>
          <name>Central</name>
          <url>http://localhost:8081/nexus/content/groups/public/</url>
          <releases>
               <enabled>true</enabled>     
          </releases>
          <snapshots>
               <enabled>false</enabled>
          </snapshots>
        </repository>
      </repositories>
    </profile>
  </profiles>
  <activeProfiles>
    <activeProfile>nexus-central</activeProfile>
  </activeProfiles>

 nexus3.x的url是

<url>http://localhost:8081/repository/maven-public/</url>

因为使用了镜像,所有这里的url没有实际意义

不配置profile,使用的默认配置是

D:\Program Files\apache-maven-3.0.5\lib\maven-model-builder-3.0.5.jar
maven-model-builder-3.0.5.jar\org\apache\maven\model\pom-4.0.0.xml

<repositories>
    <repository>
      <id>central</id>
      <name>Central Repository</name>
      <url>http://repo.maven.apache.org/maven2</url>
      <layout>default</layout>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
    </repository>
  </repositories>
发布了67 篇原创文章 · 获赞 11 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/haveqing/article/details/84518046
今日推荐