如何在Nexus存储库中使用Spring快照

时间:2019-03-16 23:07:25

标签: spring-boot maven-3 nexus

我们可以使用Nexus存储库构建Spring Boot RELEASE项目,该存储库代理maven-central并使用maven-public组。由于Maven无法解决SNAPSHOT依赖关系,因此无法构建Spring Boot 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,但这无济于事。

1 个答案:

答案 0 :(得分:0)

问题在于,目前http://repo.spring.io/snapshot上没有公开提供2.2.0.BUILD-SNAPSHOT。可用的最高版本是2.1.2.BUILD-SNAPSHOT。我与Pivotal员工一起工作,该员工必须比公众更早获得更高的内部版本号。我将pom.xml备份到2.1.1.RELEASE并成功。