简体   繁体   English

IntelliJ IDEA中的LocalDateTime Kotlin显示为未解析的引用

[英]LocalDateTime in IntelliJ IDEA Kotlin shows as unresolved reference

java.time seems to be missing entirely. java.time似乎完全没有了。 The code I'm trying it in is a simple 我正在尝试的代码很简单

fun main(args: Array<String>) {
    println(LocalDateTime.now())
}

Seems like I am missing something fundamental, but all I have been doing is following along in a tutorial and it just worked for the tutor. 好像我缺少一些基本的东西,但我一直在做的是在教程中跟随它,它只是为导师工作。

The LocalDateTime class has only been introduced in Java SE 8, so you need to compile your project against JDK 8 or newer. LocalDateTime类仅在Java SE 8中引入,因此您需要针对JDK 8或更高版本编译项目。

Make sure that: 确保:

  • You have an installed JDK 8 or newer; 您已安装JDK 8或更新版本;

  • Your project is compiled against this JDK 8+. 您的项目是针对此JDK 8+编译的。

    (In IntelliJ IDEA, Ctrl / + Shift + Alt + SProjectProject SDK ; other build systems should be set up separately) (在IntelliJ IDEA中, 按Ctrl / + Shift + Alt + S项目Project SDK ;其他构建系统应单独设置)

With the JDK configured correctly, the code should run fine as-is: (demo) 正确配置JDK后,代码应该按原样运行:( 演示)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Kotlin IntelliJ 中未解决的引用 - Kotlin unresolved reference in IntelliJ 未解决的参考 -intelliJ Kotlin 程序 - unresolved reference -intelliJ Kotlin programs IntelliJ 在 Fabric Kotlin 开发环境中显示对 java.lang.String#replace 的未解决引用 - IntelliJ shows unresolved reference to java.lang.String#replace in Fabric Kotlin dev environment IntelliJ (Kotlin) 视觉未解决的参考错误 - IntelliJ (Kotlin) Visual Unresolved Reference Bug TornadoFX _ Kotlin _ IntelliJ IDEA:由于我在项目中使用 openJDK 8,我怎么可能得到“未解决的参考:javafx”? - TornadoFX _ Kotlin _ IntelliJ IDEA: How is it possible that I am getting an “Unresolved reference: javafx” since I am using openJDK 8 in my project? IntelliJ 中混合 Java/Kotlin 多模块项目中未解决的 Kotlin 参考 - Unresolved Kotlin reference in mixed Java/Kotlin multimodule project in IntelliJ IntelliJ IDEA 对所有内容(Python、虚拟环境)都表示“未解决的引用” - IntelliJ IDEA says "unresolved reference" on everything (Python, virtual environment) Spring Web, Kotlin, Gradle, Intelresolvedli问题 - Spring Web, Kotlin, Gradle, IntelliJ -> MongoRepository “Unresolved reference: save” problem Kotlin未解决的参考问题 - Kotlin unresolved reference issue Kotlin:未解决的参考:java - Kotlin: Unresolved reference: java
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM