为了账号安全,请及时绑定邮箱和手机立即绑定

无法在 gradle.properties 中保留依赖项版本

无法在 gradle.properties 中保留依赖项版本

长风秋雁 2023-11-10 15:31:16
我需要在 gradle.properties 中保留依赖项的版本。gradle.properties:springBootVersion = '2.1.9.RELEASE'构建.gradle:plugins {    id 'io.spring.dependency-management' version '1.0.8.RELEASE'    id 'org.springframework.boot' version '2.1.9.RELEASE'}subprojects {    repositories {        mavenCentral()    }    configurations.all {        resolutionStrategy {            failOnVersionConflict()        }    }    apply plugin: 'java'    apply plugin: 'io.spring.dependency-management'    dependencyManagement {        dependencies {            dependency "org.springframework.boot:spring-boot-starter-web:${springBootVersion}"            dependency "org.springframework.boot:spring-boot-starter-test:${springBootVersion}"        }    }    sourceCompatibility = 11    targetCompatibility = 11    tasks.withType(JavaCompile){        options.encoding = 'UTF-8'    }}设置.gradle:include 'api'api/build.gradle:apply plugin: 'org.springframework.boot'archivesBaseName = 'phone-gift-processing-api'dependencies {    implementation 'org.springframework.boot:spring-boot-starter-web'    testImplementation 'org.springframework.boot:spring-boot-starter-test'}输出./gradlew clean build:> Task :api:compileJava FAILEDFAILURE: Build failed with an exception.* What went wrong:Execution failed for task ':api:compileJava'.> Could not resolve all files for configuration ':api:compileClasspath'.   > Could not find org.springframework.boot:spring-boot-starter-web:'2.1.9.RELEASE'.     Required by:         project :api即,Gradle 使用springBootVersion,但由于某种原因无法绑定依赖项。当我替换${springBootVersion}为时${springBootVersion},构建成功。
查看完整描述

1 回答

?
交互式爱情

TA贡献1712条经验 获得超3个赞

你的格式有误gradle.properties。而不是这个:

springBootVersion = '2.1.9.RELEASE'

尝试这个:

springBootVersion=2.1.9.RELEASE

(空格是可选的,但重要的是值周围不应有引号。)


查看完整回答
反对 回复 2023-11-10
  • 1 回答
  • 0 关注
  • 95 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信