Gradle 无法解析 Spring Boot HATEOAS 依赖

问题描述 投票:0回答:3

我从 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')
}
java spring spring-boot gradle
3个回答
1
投票

本声明

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

导致错误。更改为

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

这就是幕后的内容


0
投票

您已经在此处指定了 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')

希望这有帮助


0
投票

如果您像我一样多年后阅读此答案,请注意

compile
已被弃用,并且自 Gradle 7.0 起已被删除。相反,将其更改为
implementation
,这样就可以了:

implementation 'org.springframework.boot:spring-boot-starter-hateoas'

© www.soinside.com 2019 - 2024. All rights reserved.