尝试使用kotlin插件jpa时出现错误,并且我的项目无法在本地编译,因为Intellij返回以下错误:
“使用先前的依赖关系,构建配置失败”
按照我的build.gradle文件以下
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
plugins {
id("org.springframework.boot") version "2.1.5.RELEASE"
id("io.spring.dependency-management") version "1.0.7.RELEASE"
id("org.jetbrains.kotlin.plugin.jpa") version "1.3.31"
kotlin("jvm") version "1.2.71"
kotlin("plugin.spring") version "1.2.71"
}
group = "br.com"
version = "0.0.1-SNAPSHOT"
java.sourceCompatibility = JavaVersion.VERSION_1_8
repositories {
mavenCentral()
}
dependencies {
implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.jetbrains.kotlin:kotlin-reflect")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
testImplementation("org.springframework.boot:spring-boot-starter-test")
runtime("org.postgresql:postgresql")
}
tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "1.8"
}
}
答案 0 :(得分:1)
您的版本不匹配:JPA插件(org.jetbrains.kotlin.plugin.jpa
)设置为版本1.3.31
,但是Kotlin(kotlin("jvm")
)和Kotlin Spring(kotlin("plugin.spring")
)插件设置为1.2.71
版。我建议您通过更改以下两行,将所有内容移至1.3.31
:
kotlin("jvm") version "1.3.31"
kotlin("plugin.spring") version "1.3.31"