kotlin:spring 和 kapt 不能一起工作
kotlin: spring and kapt not working together
我使用 spring initializr 创建了一个 kotlin/gradle 项目。
如前所述 here,如果我尝试添加 kapt,如:
plugins {
kotlin("plugin.jpa") version "1.2.71"
id("org.springframework.boot") version "2.1.6.RELEASE"
id("io.spring.dependency-management") version "1.0.7.RELEASE"
kotlin("jvm") version "1.2.71"
kotlin("plugin.spring") version "1.2.71"
--> kotlin("kapt") version "1.3.41"
}
我一尝试编译代码就收到以下错误:
Caused by: org.gradle.internal.event.ListenerNotificationException: Failed to notify project evaluation listener.
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:86)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:324)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:234)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:140)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy37.afterEvaluate(Unknown Source)
at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.execute(LifecycleProjectEvaluator.java:190)
at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.execute(LifecycleProjectEvaluator.java:187)
at org.gradle.api.internal.project.DefaultProject.stepEvaluationListener(DefaultProject.java:1424)
at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:196)
[...]
Caused by: java.lang.AbstractMethodError: org.jetbrains.kotlin.noarg.gradle.NoArgKotlinGradleSubplugin.getNativeCompilerPluginArtifact()Lorg/jetbrains/kotlin/gradle/plugin/SubpluginArtifact;
at org.jetbrains.kotlin.gradle.plugin.SubpluginEnvironment.addSubpluginOptions(SubpluginEnvironment.kt:81)
at org.jetbrains.kotlin.gradle.plugin.SubpluginEnvironment.addSubpluginOptions(SubpluginEnvironment.kt:51)
at org.jetbrains.kotlin.gradle.plugin.Kotlin2JvmSourceSetProcessor$doTargetSpecificProcessing.invoke(KotlinPlugin.kt:184)
at org.jetbrains.kotlin.gradle.plugin.Kotlin2JvmSourceSetProcessor$doTargetSpecificProcessing.invoke(KotlinPlugin.kt:161)
at org.jetbrains.kotlin.gradle.plugin.RunOnceAfterEvaluated.execute(RunOnceAfterEvaluated.kt:25)
at org.jetbrains.kotlin.gradle.plugin.RunOnceAfterEvaluated.onEvaluated(RunOnceAfterEvaluated.kt:34)
at org.jetbrains.kotlin.gradle.plugin.RunOnceAfterEvaluatedKt$runOnceAfterEvaluated.execute(RunOnceAfterEvaluated.kt:56)
at org.jetbrains.kotlin.gradle.plugin.RunOnceAfterEvaluatedKt$runOnceAfterEvaluated.execute(RunOnceAfterEvaluated.kt)
我通过将 jvm 插件升级到与 kapt 相同的版本来解决它。
最后我把所有的插件都更新到了最新版本
我使用 spring initializr 创建了一个 kotlin/gradle 项目。 如前所述 here,如果我尝试添加 kapt,如:
plugins {
kotlin("plugin.jpa") version "1.2.71"
id("org.springframework.boot") version "2.1.6.RELEASE"
id("io.spring.dependency-management") version "1.0.7.RELEASE"
kotlin("jvm") version "1.2.71"
kotlin("plugin.spring") version "1.2.71"
--> kotlin("kapt") version "1.3.41"
}
我一尝试编译代码就收到以下错误:
Caused by: org.gradle.internal.event.ListenerNotificationException: Failed to notify project evaluation listener.
at org.gradle.internal.event.AbstractBroadcastDispatch.dispatch(AbstractBroadcastDispatch.java:86)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:324)
at org.gradle.internal.event.BroadcastDispatch$CompositeDispatch.dispatch(BroadcastDispatch.java:234)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:140)
at org.gradle.internal.event.ListenerBroadcast.dispatch(ListenerBroadcast.java:37)
at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy37.afterEvaluate(Unknown Source)
at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.execute(LifecycleProjectEvaluator.java:190)
at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.execute(LifecycleProjectEvaluator.java:187)
at org.gradle.api.internal.project.DefaultProject.stepEvaluationListener(DefaultProject.java:1424)
at org.gradle.configuration.project.LifecycleProjectEvaluator$NotifyAfterEvaluate.run(LifecycleProjectEvaluator.java:196)
[...]
Caused by: java.lang.AbstractMethodError: org.jetbrains.kotlin.noarg.gradle.NoArgKotlinGradleSubplugin.getNativeCompilerPluginArtifact()Lorg/jetbrains/kotlin/gradle/plugin/SubpluginArtifact;
at org.jetbrains.kotlin.gradle.plugin.SubpluginEnvironment.addSubpluginOptions(SubpluginEnvironment.kt:81)
at org.jetbrains.kotlin.gradle.plugin.SubpluginEnvironment.addSubpluginOptions(SubpluginEnvironment.kt:51)
at org.jetbrains.kotlin.gradle.plugin.Kotlin2JvmSourceSetProcessor$doTargetSpecificProcessing.invoke(KotlinPlugin.kt:184)
at org.jetbrains.kotlin.gradle.plugin.Kotlin2JvmSourceSetProcessor$doTargetSpecificProcessing.invoke(KotlinPlugin.kt:161)
at org.jetbrains.kotlin.gradle.plugin.RunOnceAfterEvaluated.execute(RunOnceAfterEvaluated.kt:25)
at org.jetbrains.kotlin.gradle.plugin.RunOnceAfterEvaluated.onEvaluated(RunOnceAfterEvaluated.kt:34)
at org.jetbrains.kotlin.gradle.plugin.RunOnceAfterEvaluatedKt$runOnceAfterEvaluated.execute(RunOnceAfterEvaluated.kt:56)
at org.jetbrains.kotlin.gradle.plugin.RunOnceAfterEvaluatedKt$runOnceAfterEvaluated.execute(RunOnceAfterEvaluated.kt)
我通过将 jvm 插件升级到与 kapt 相同的版本来解决它。 最后我把所有的插件都更新到了最新版本