【发布时间】:2024-11-20 04:15:02
【问题描述】:
从 Spring Boot 1.5.8 迁移到 2.1.5,得到错误信息:
无法为 org.gradle.api.Project 类型的项目 ':api' 设置未知属性 'sourceCompatibility'。
如果我评论该行,我会收到错误消息:
无法为 org.gradle.api.Project 类型的项目“:api”设置未知属性“targetCompatibility”。
如果我评论该行,我会收到错误消息:
在 org.gradle.api.Project 类型的项目 ':api' 上找不到参数 [build_4wobgm6qykoy29e0in3cntga8$_run_closure2@1fc9b06d] 的方法 jar()。
所以有些东西不在这里。我有两个build.gradle 文件,一个在我的根目录,一个在api:
/build.gradle
plugins {
id 'idea'
id 'java'
id 'com.jfrog.bintray' version '1.8.4'
}
apply from: "$rootDir/gradle/git-version.gradle"
version getVersionFromGit()
group 'com.my_org.my_proj'
apply from: "$rootDir/gradle/bintray-vars.gradle"
subprojects {
repositories {
jcenter()
mavenCentral()
}
}
wrapper {
gradleVersion = '4.8.1'
}
/api/build.gradle
plugins {
id 'org.springframework.boot' version '2.1.5.RELEASE'
id 'io.spring.dependency-management' version '1.0.7.RELEASE'
}
group = rootProject.group
version = rootProject.version
repositories {
maven { url 'https://dl.bintray.com/my-org/spring-utils' }
}
apply from: "$rootDir/gradle/checkstyle.gradle"
sourceCompatibility = 1.8
targetCompatibility = 1.8
jar {
archiveName = 'api.jar'
baseName = project.name
version = project.version
}
test {
doFirst {
environment "BUILD_NUMBER", "1"
}
}
dependencies {
def springBoot = '2.1.5.RELEASE'
runtime group: 'org.springframework.boot', name: 'spring-boot-properties-migrator', version: springBoot
compile group: 'org.flywaydb', name: 'flyway-core', version: '5.2.4'
compile group: 'org.hibernate', name: 'hibernate-java8', version: '5.4.3.Final'
compile group: 'org.springframework.boot', name: 'spring-boot-starter-web', version: springBoot
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-jpa', version: springBoot
compile group: 'org.springframework.boot', name: 'spring-boot-starter-data-rest', version: springBoot
compile group: 'org.springframework.boot', name: 'spring-boot-starter-mail', version: springBoot
compile group: 'org.springframework.boot', name: 'spring-boot-starter-freemarker', version: springBoot
testCompile group: 'junit', name: 'junit', version: '4.12'
testCompile group: 'org.springframework.boot', name: 'spring-boot-starter-test', version: springBoot
testCompile group: 'org.flywaydb.flyway-test-extensions', name: 'flyway-spring-test', version: '4.2.0.2'
}
我显然在这里遗漏了一些东西。当然,我一直在关注migration guide 以及谷歌搜索。有什么建议吗?
【问题讨论】:
标签: java spring spring-boot gradle