简体   繁体   English

在IntelliJ IDEA中编译错误:“没有MessageCollector”

[英]Error compiling in IntelliJ IDEA: “No MessageCollector”

Edit: Solved. 编辑:解决了。 See @acdsee comment to see how . 请参阅@acdsee评论以了解具体方法

Since when I updated IntelliJ IDEA from 2017.3.5 to 2018.1, every project I start throws this error: 自从我将IntelliJ IDEA从2017.3.5更新到2018.1以来,我开始的每个项目都抛出了这个错误:

> Error:Module 'JBA' production: java.lang.Exception: LOGGING: Loading
> modules: [java.se, javafx.base, javafx.controls, javafx.fxml,
> javafx.graphics, javafx.media, javafx.swing, javafx.web,
> jdk.accessibility, jdk.attach, jdk.compiler, jdk.dynalink,
> jdk.httpserver, jdk.incubator.httpclient, jdk.jartool, jdk.javadoc,
> jdk.jconsole, jdk.jdi, jdk.jfr, jdk.jshell, jdk.jsobject,
> jdk.management, jdk.management.cmm, jdk.management.jfr,
> jdk.management.resource, jdk.net, jdk.packager, jdk.packager.services,
> jdk.scripting.nashorn, jdk.sctp, jdk.security.auth, jdk.security.jgss,
> jdk.unsupported, jdk.xml.dom, oracle.desktop, oracle.net, java.base,
> java.compiler, java.datatransfer, java.desktop, java.xml,
> java.instrument, java.logging, java.management, java.management.rmi,
> java.rmi, java.naming, java.prefs, java.scripting, java.security.jgss,
> java.security.sasl, java.sql, java.sql.rowset, java.xml.crypto,
> jdk.internal.jvmstat, jdk.management.agent, jdk.jdwp.agent,
> jdk.internal.ed, jdk.internal.le, jdk.internal.opt, jdk.jlink] (no
> MessageCollector configured)

I had the same problem with Kotlin 1.2.40 and Java JDK 10. After every change in the code, I had to rebuild the whole project to get rid of the compilation error. 我遇到了与Kotlin 1.2.40和Java JDK 10相同的问题。在代码中的每次更改之后,我不得不重建整个项目以摆脱编译错误。 Deleting of the out folder did help only until the next change. 删除out文件夹确实只对下一次更改有帮助。 I was looking for the way to downgrade the Kotlin plugin to the previous version, but have found a better solution. 我一直在寻找将Kotlin插件降级到之前版本的方法,但是找到了更好的解决方案。

My IDEA project didn't have Gradle and I was able to solve the problem by adding Gradle to the project. 我的IDEA项目没有Gradle,我可以通过将Gradle添加到项目中来解决问题。

Just close the Project, put the following file "build.gradle" to the root folder and re-import the Project in the IntelliJ IDEA. 只需关闭Project,将以下文件“build.gradle”放到根文件夹中,然后在IntelliJ IDEA中重新导入Project。

My file build.gradle looks so: 我的文件build.gradle看起来如此:

buildscript {
    ext.kotlin_version = '1.2.40'

    repositories {
        mavenCentral()
    }

    dependencies {
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

apply plugin: 'kotlin'

sourceSets {
    main.java.srcDirs += 'src'
}

repositories {
    mavenCentral()
}

dependencies {
    compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8"
}

It works well now with the Plugin Version 1.2.40. 它现在适用于插件版本1.2.40。 A downgrade to a previous version is not necessary. 不必降级到以前的版本。

Promoting the answer in the comments to an answer, because it's the actual answer: 在评论中将答案提升为答案,因为这是实际的答案:

This appears to be a bug in the IntelliJ Kotlin plugin v1.2.40 and how it interacts with Java 10. See here . 这似乎是IntelliJ Kotlin插件v1.2.40中的一个错误以及它与Java 10的交互方式。请参见此处 The solution is to upgrade to v1.2.41. 解决方案是升级到v1.2.41。

(Don't switch your project to building with Gradle like the other answer suggests just because the plugin is broken. That's weird.) (不要将你的项目转换为使用Gradle构建,就像其他答案所表明的那样,因为插件已经坏了。这很奇怪。)

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM