首页 > 解决方案 > 如何在 Nexus 存储库中使用 Spring 快照

问题描述

我们使用代理 maven-central 并使用 maven-public 组的 Nexus 存储库构建 Spring Boot RELEASE 项目没有问题。Spring Boot SNAPSHOT 项目不会构建,因为 Maven 无法解析 SNAPSHOT 依赖项。Spring SNAPSHOTS 已下载,但随后我们收到此错误消息。

Failure to find org.springframework.cloud:spring-cloud-starter-zipkin:jar:2.2.0.BUILD-SNAPSHOT
in http://[host]:8081/repository/[snapshots] was cached in the local
repository, resolution will not be reattempted until the update
interval of [snapshots] has elapsed or updates are forced

以下是设置:

<settings>
<mirrors>
    <mirror>
        <id>nexus-proxy-maven-central</id>
        <name>maven-central</name>
        <url>http://[host]/repository/maven-central</url>
        <mirrorOf>central</mirrorOf>
    </mirror>
</mirrors>
<profiles>
    <profile>
        <id>nexus</id>
        <activation>
            <activeByDefault>true</activeByDefault>
        </activation>
        <repositories>
            <repository>
                <id>maven-public</id>
                <name>maven-public</name>
                <url>http://[host]/repository/maven-public</url>
                <layout>default</layout>
            </repository>
        </repositories>
        <pluginRepositories>
        <pluginRepository>
          <id>spring-milestone</id>
          <name>Spring Milestone Repository</name>
          <url>https://repo.spring.io/milestone</url>
        </pluginRepository>
        <pluginRepository>
          <id>maven-public</id>
          <name>maven-public</name>
          <url>http://[host]/repository/maven-public</url>
        </pluginRepository>
      </pluginRepositories>
    </profile>
</profiles>
<servers>
    <server>
        <id>[snapshots]</id>
        <username>*</username>
        <password>*</password>
    </server>
    <server>
        <id>[releases]</id>
        <username>*</username>
        <password>*</password>
    </server>
    <server>
        <id>maven-public</id>
        <username>*</username>
        <password>*</password>
    </server>
    <server>
        <id>maven-central</id>
        <username>*</username>
        <password>*</password>
</servers>
</settings>

pom 看起来像这样:

<distributionManagement>
  <repository>
    <id>[releases]</id>
    <url>https://[host]/repository/[releases]/</url>
  </repository>
  <snapshotRepository>
    <id>[snapshots]</id>
    <url>https://[host]/repository/[snapshots]/</url>
  </snapshotRepository>
</distributionManagement>

<repositories>
    <repository>
      <id>repository.spring.snapshot</id>
      <name>Spring Snapshot Repository</name>
      <url>http://repo.spring.io/snapshot</url>
      <releases><enabled>false</enabled></releases>
      <snapshots><enabled>true</enabled></snapshots>
    </repository>
    <repository>
      <id>repository.spring.milestone</id>
      <name>Spring Milestone Repository</name>
      <url>http://repo.spring.io/milestone</url>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
        <checksumPolicy>warn</checksumPolicy>
      </releases>
      <snapshots><enabled>false</enabled></snapshots>
    </repository>
    <repository>
      <id>[releases]</id>
      <name>[releases]</name>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>always</updatePolicy>
        <checksumPolicy>warn</checksumPolicy>
      </releases>
      <snapshots><enabled>false</enabled></snapshots>
      <url>http://[host]/repository/[releases]</url>
      <layout>default</layout>
    </repository>
    <repository>
      <id>[snapshots]</id>
      <name>[snapshots]</name>
      <releases><enabled>false</enabled></releases>
      <snapshots><enabled>true</enabled></snapshots>
      <url>http://[host]/repository[snapshots]</url>
      <layout>default</layout>
    </repository>
</repositories>

我尝试使用和不使用 Nexus 代理来构建 Spring Snapshots,但它没有帮助。

标签: spring-bootmaven-3nexus

解决方案


问题是 2.2.0.BUILD-SNAPSHOT 目前不在http://repo.spring.io/snapshot上公开可用。可用的最高版本是 2.1.2.BUILD-SNAPSHOT。我与一名 Pivotal 员工一起工作,他必须比公众更早地获得更高的内部版本号。我支持我的 pom.xml 到 2.1.1.RELEASE 并且它工作。


推荐阅读