【问题标题】:Gradle cannot resolve Spring Boot HATEOAS dependencyGradle 无法解析 Spring Boot HATEOAS 依赖
【发布时间】:2019-01-27 16:32:10
【问题描述】:

我从 http://start.spring.io 创建了我的骨架项目。但是当我构建应用程序时,Gradle 无法解析 HATEOAS 依赖项。这是我得到的错误:

错误:java:索引 78 处的非法字符 <:>: C:\Users\TempUser\Downloads\hateoas\无法解析 org.springframework.boot:spring-boot-starter-hateoas:2.0.4.RELEASE.

这是我的build.gradle 文件:

buildscript {
    ext {
        springBootVersion = '2.0.4.RELEASE'
    }
    repositories {
        mavenCentral()
    }
    dependencies {
        classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
    }
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

group = 'com.example'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
    mavenCentral()
}


dependencies {
    compile('org.springframework.boot:spring-boot-starter-data-jpa')
    compile('org.springframework.boot:spring-boot-starter-hateoas:2.0.4.RELEASE')
    compile('org.springframework.boot:spring-boot-starter-web')
    testCompile('org.springframework.boot:spring-boot-starter-test')
}

【问题讨论】:

  • 我认为您不应该为 spring-boot-starter 依赖项指定版本。查看您拥有的其他三个依赖项 - 使失败的依赖项看起来像那些! :)
  • 您在 Spring initializr 中指定了哪些依赖项?您是否手动添加了 HATEOAS 依赖项?
  • 我在创建项目时指定了web、jpa和hateoas依赖。

标签: java spring spring-boot gradle


【解决方案1】:

此声明

compile('org.springframework.boot:spring-boot-starter-hateoas:2.0.4.RELEASE')

导致错误。改为

compile('org.springframework.boot:spring-boot-starter-hateoas')

这就是引擎盖下的内容

【讨论】:

  • 我删除了版本,但仍然有同样的错误。
  • 我已经删除了版本号,但我仍然有同样的问题。
  • 我使用你的文件build.gradle,没问题user-images.githubusercontent.com/1328316/…
  • 尝试安装最新版本的Gradle(4.9),并检查fireware、proxy,删除本地所有Maven。
  • 谢谢@Do Nhu Vy。问题是我的代理。我不得不把它关掉。
【解决方案2】:

您已经在这里指定了 Spring Boot 组件的版本:

ext {
    springBootVersion = '2.0.4.RELEASE'
}

因此,所有 starter 依赖项都必须在没有版本值的情况下指定。使用:

compile('org.springframework.boot:spring-boot-starter-hateoas')

而不是

compile('org.springframework.boot:spring-boot-starter-hateoas:2.0.4.RELEASE')

希望对你有帮助

【讨论】:

  • 我已经删除了版本号,但我仍然有同样的错误信息。
猜你喜欢
  • 2015-05-10
  • 2019-04-24
  • 1970-01-01
  • 2015-12-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-13
  • 2016-09-02
相关资源
最近更新 更多