Intellij问题解决了Spring Kotlin的依赖性 [英] Intellij issue resolving dependency for spring kotlin

查看:638
本文介绍了Intellij问题解决了Spring Kotlin的依赖性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Intellij给我全新的kotlin/spring项目到处都是错误,我无法从IDE构建或运行该项目.

Intellij is giving me errors all around for brand new kotlin/spring project and I cannot build or run the project from the IDE.

但是,如果我从命令行执行此操作,则不会出现任何问题,并且可以构建和运行该应用程序.

If I do it from the command line however, there are no issues and I can build and run the app.

'classpath' in 'org.gradle.api.artifacts.dsl.DependencyHandler' cannot be applied to '(groovy.lang.GString)'
'apply' in 'org.gradle.api.plugins.PluginAware' cannot be applied to '(['plugin':java.lang.String])'

Cannot access class 'java.lang.String'. Check your module classpath for missing or conflicting dependencie

Type mismatch.
Required:
java.lang.String
Found:
kotlin.String

关于可能是什么问题的任何想法? 我在InteliJ中尝试了 Kotlin多平台JVM类型不匹配,但似乎没有解决该问题.

Any ideas to what may be the issue? I tried Kotlin multiplatform JVM type mismatch in InteliJ but doesn't seem to fix the issue.

更新:

清除gradle缓存,重新安装Intellij,从start.spring.io创建并选择Gradle和Kotlin的Import项目.

Cleared gradle caches, reinstalled Intellij, Import project that was created from start.spring.io with Gradle and Kotlin selected.

使用默认的gradle包装器和项目jdk(路径表示jre)?给我一个错误.打开gradle设置只会打开文件资源管理器.

Using default gradle wrapper and project jdk (the path says jre)? gives me an error. Open gradle settings just opens the file explorer.

使用默认的gradle包装器和计算机本地JDK时,上面的依赖项存在相同的问题.

Using default gradle wrapper and machine local JDK same issues with the dependencies from above.

推荐答案

如果您在IntelliJ中设置了自己的模块,并且您认为由于正在执行Kotlin(Maven)项目,则应该设置SDK,从而会出现此问题.到科特林.错了!

This issue comes up if you set up your own module inside IntelliJ and you think that since you are doing a Kotlin (Maven) project, the SDK should be set to Kotlin. Wrong!

问题显示在第一张图像中.项目SDK设置为Kotlin.

The problem is shown in the first image. The project SDK is set to Kotlin.

将其更改为Java.大概任何8种以上的Java都足够了.

Change it to Java. Probably any 8+ Java will be good enough.

这可以解决IDE错误和编译器错误.

This solves the IDE errors and the compiler errors as well.

这篇关于Intellij问题解决了Spring Kotlin的依赖性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆