我需要在 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
(空格是可選的,但重要的是值周圍不應有引號。)
添加回答
舉報
0/150
提交
取消