以下是我的build.gradle
buildscript {
ext {
springBootVersion = '2.0.0.M3'
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
}
}
apply plugin: 'org.springframework.boot'
apply plugin: 'maven-publish'
dependencyManagement {
imports {
mavenBom 'org.springframework.cloud:spring-cloud-starter-parent:Brixton.SR7'
}
}
dependencies {
compile("org.springframework.cloud:spring-cloud-starter-eureka")
compile "org.elasticsearch:elasticsearch:5.5.0"
testCompile('org.springframework.boot:spring-boot-starter-test')
}
我使用gradle 2.14并得到以下错误
> Failed to apply plugin [id 'org.springframework.boot']
> Spring Boot plugin requires Gradle 3.4 or later. The current version is Gra
dle 2.14
然后我按照错误消息中的建议将gradle升级到3.4。
现在我收到以下错误
无法为参数[build_79bcact4bkf1找到方法dependencyManagement() 根项目'myproject'上的sckkod1j3zl7l $ _run_closure1 @ 4a2d71c9] 类型为org.gradle.api.Project。
gradle 3.4中的方法dependencyManagement()是否不再可用? 如果有人知道在gradle 3.4中使用的替代方法,请退回
答案 0 :(得分:18)
要使用此DSL
,您必须提供dependency-management-plugin:
buildscript {
repositories {
maven {
jcenter() //or mavenCentral()
}
}
dependencies {
classpath "io.spring.gradle:dependency-management-plugin:1.0.3.RELEASE"
}
}
apply plugin: "io.spring.dependency-management"
或者您可以使用:
plugins {
id "io.spring.dependency-management" version "1.0.3.RELEASE"
}