使用 Gradle 启动 2.0.0.BUILD-SNAPSHOT 时出错

Posted

技术标签:

【中文标题】使用 Gradle 启动 2.0.0.BUILD-SNAPSHOT 时出错【英文标题】:Error with Boot 2.0.0.BUILD-SNAPSHOT using Gradle 【发布时间】:2017-08-31 03:24:02 【问题描述】:

我从 https://start.spring.io 创建了一个版本为 2.0.0.BUILD-SNAPSHOT 的 Gradle 启动项目,并且没有进行任何更改,并尝试使用以下命令运行应用程序:

gradle bootRun

我收到以下错误

    FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not find org.springframework.boot:spring-boot-starter-actuator:.
  Searched in the following locations:
      https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-actuator//spring-boot-starter-actuator-.pom
      https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-actuator//spring-boot-starter-actuator-.jar
      https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-actuator//spring-boot-starter-actuator-.pom
      https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-actuator//spring-boot-starter-actuator-.jar
      https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-actuator//spring-boot-starter-actuator-.pom
      https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-actuator//spring-boot-starter-actuator-.jar

现在,当我将版本更改为: springBootVersion = '1.5.3.BUILD-SNAPSHOT'应用启动正常。

我怀疑依赖管理 $springBootVersion 标签有问题,如图所示:

https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-actuator/[版本在哪里???]/spring-boot-starter-actuator-[版本在哪里???].pom

这是我配置的存储库(粗体不是由 INITIALZR 自动生成的:

repositories 
    mavenCentral()
    maven  url 'https://repo.spring.io/libs-snapshot' 
    maven  url "https://repo.spring.io/snapshot" 
    maven  url "https://repo.spring.io/milestone" 

这可能对某些依赖项有所帮助,但 starter pom 仍然存在问题:

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not find org.springframework.boot:spring-boot-starter-aop:.
  Searched in the following locations:
      https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-aop//spring-boot-starter-aop-.pom
      https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-aop//spring-boot-starter-aop-.jar
      https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-aop//spring-boot-starter-aop-.pom
      https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-aop//spring-boot-starter-aop-.jar
      https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-aop//spring-boot-starter-aop-.pom
      https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-aop//spring-boot-starter-aop-.jar
  Required by:
      project :
> Could not find org.springframework.boot:spring-boot-starter-jdbc:.
  Searched in the following locations:
      https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-jdbc//spring-boot-starter-jdbc-.pom
      https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-jdbc//spring-boot-starter-jdbc-.jar
      https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-jdbc//spring-boot-starter-jdbc-.pom
      https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-jdbc//spring-boot-starter-jdbc-.jar
      https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-jdbc//spring-boot-starter-jdbc-.pom
      https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-jdbc//spring-boot-starter-jdbc-.jar
  Required by:
      project :
> Could not find org.springframework.boot:spring-boot-starter-data-rest:.
  Searched in the following locations:
      https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-data-rest//spring-boot-starter-data-rest-.pom
      https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-data-rest//spring-boot-starter-data-rest-.jar
      https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-data-rest//spring-boot-starter-data-rest-.pom
      https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-data-rest//spring-boot-starter-data-rest-.jar
      https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-data-rest//spring-boot-starter-data-rest-.pom
      https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-data-rest//spring-boot-starter-data-rest-.jar
  Required by:
      project :
> Could not find com.h2database:h2:.
  Searched in the following locations:
      https://repo1.maven.org/maven2/com/h2database/h2//h2-.pom
      https://repo1.maven.org/maven2/com/h2database/h2//h2-.jar
      https://repo.spring.io/snapshot/com/h2database/h2//h2-.pom
      https://repo.spring.io/snapshot/com/h2database/h2//h2-.jar
      https://repo.spring.io/milestone/com/h2database/h2//h2-.pom
      https://repo.spring.io/milestone/com/h2database/h2//h2-.jar
  Required by:
      project :
> Could not find org.hsqldb:hsqldb:.
  Searched in the following locations:
      https://repo1.maven.org/maven2/org/hsqldb/hsqldb//hsqldb-.pom
      https://repo1.maven.org/maven2/org/hsqldb/hsqldb//hsqldb-.jar
      https://repo.spring.io/snapshot/org/hsqldb/hsqldb//hsqldb-.pom
      https://repo.spring.io/snapshot/org/hsqldb/hsqldb//hsqldb-.jar
      https://repo.spring.io/milestone/org/hsqldb/hsqldb//hsqldb-.pom
      https://repo.spring.io/milestone/org/hsqldb/hsqldb//hsqldb-.jar
  Required by:
      project :
> Could not find org.springframework.boot:spring-boot-starter-security:.
  Searched in the following locations:
      https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-security//spring-boot-starter-security-.pom
      https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-security//spring-boot-starter-security-.jar
      https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-security//spring-boot-starter-security-.pom
      https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-security//spring-boot-starter-security-.jar
      https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-security//spring-boot-starter-security-.pom
      https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-security//spring-boot-starter-security-.jar
  Required by:
      project :
> Could not find org.springframework.boot:spring-boot-starter-web:.
  Searched in the following locations:
      https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-web//spring-boot-starter-web-.pom
      https://repo1.maven.org/maven2/org/springframework/boot/spring-boot-starter-web//spring-boot-starter-web-.jar
      https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-web//spring-boot-starter-web-.pom
      https://repo.spring.io/snapshot/org/springframework/boot/spring-boot-starter-web//spring-boot-starter-web-.jar
      https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-web//spring-boot-starter-web-.pom
      https://repo.spring.io/milestone/org/springframework/boot/spring-boot-starter-web//spring-boot-starter-web-.jar

【问题讨论】:

发布你的整个 build.gradle 【参考方案1】:

你需要添加:

maven 
    url 'https://repo.spring.io/libs-snapshot'

到您的存储库块(主要和构建脚本)

【讨论】:

这可能对某些依赖项有所帮助,但 starter pom 仍然存在问题: 我两个都有。问题在于那些 REPO 中的启动器。他们错了:repo1.maven.org/maven2/org/springframework/boot/…MISSING]/spring-boot-starter-aop-[VERSION MISSING].pom BUILD-SNAPSHOT 版本不在 maven 中心。你找错地方了。看这里:repo.spring.io/libs-snapshot/org/springframework/boot/…

以上是关于使用 Gradle 启动 2.0.0.BUILD-SNAPSHOT 时出错的主要内容,如果未能解决你的问题,请参考以下文章

Gradle > 如何停止使用 gradle bootRun 启动的 Spring Boot 应用程序?

如何编写 Gradle 启动脚本

gradle bootRun:应用程序无法使用类路径启动

解决Maven依赖下载不全的问题

gradle 命令失败,因为它无法启动守护进程

如何显示使用类而不是Gradle Suite的报表门户启动?