Java Intellij Idea赢得';我不编译kotlin,但maven编译
我有一个项目,它包含混合的kotlin和基于maven的java代码。如果我用maven(从命令行)编译该项目,就可以了Java Intellij Idea赢得';我不编译kotlin,但maven编译,java,maven,intellij-idea,kotlin,Java,Maven,Intellij Idea,Kotlin,我有一个项目,它包含混合的kotlin和基于maven的java代码。如果我用maven(从命令行)编译该项目,就可以了 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] T
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 30.830 s
[INFO] Finished at: 2017-05-19T07:42:55+01:00
[INFO] Final Memory: 44M/482M
[INFO] ------------------------------------------------------------------------
爪哇:
想法:
马文:
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /Library/apache-maven-3.3.9/apache-maven-3.3.9
Java version: 1.8.0_91, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre
Default locale: cs_CZ, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.3", arch: "x86_64", family: "mac"
Maven配置:
<project>
..
<properties>
<kotlin.version>1.1.2-2</kotlin.version>
</properties>
..
<dependencies>
..
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jre8</artifactId>
<version>${kotlin.version}</version>
</dependency>
..
</dependencies>
<build>
<plugins>
..
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<configuration>
<jvmTarget>1.8</jvmTarget>
<languageVersion>1.1</languageVersion>
<apiVersion>1.1</apiVersion>
</configuration>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/java</source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>process-test-sources</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/test/java</source>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
..
<plugins>
</build>
</project>
请问,您是否知道如何在IntelliJ idea中也能使用它?有时,在
.idea
和/或*.iml
文件下的项目设置中会设置一些内容,最简单的方法是从头开始IntelliJ idea项目
如果您的项目受源代码管理(例如,使用git scm),则只需删除本地克隆,再次克隆,然后重新创建项目
如果无法执行此操作,则可以手动删除.idea
文件夹和任何*.iml
文件。请注意,IML文件可能位于项目的根目录和子目录中。当项目未在IntelliJ IDEA中打开时,您需要删除这些文件,否则当您关闭项目时,可能会将其中一些文件写回文件系统
重新创建项目通常是万不得已的办法,但有时当项目无法正常运行且您无法找出原因时,这是最简单的方法。请尝试使用文件|使缓存无效作为快速的第一步;这可能会有帮助。谢谢你的建议,但不幸的是,这不起作用-它的行为完全相同。(我尝试使缓存无效并重新启动)下一个快速尝试是重新导入Maven项目(“Maven项目工具窗口中的“重新导入所有Maven项目”)。您可能还需要在IntelliJ IDEA中检查Kotlin插件版本。@mfulton26这解决了我的问题。如果问题在.iml文件中,如果我只删除.idea文件夹,它的行为方式相同,但如果我删除所有idea内容(包括.iml),它就像一个符咒:-)非常感谢
Apache Maven 3.3.9 (bb52d8502b132ec0a5a3f4c09453c07478323dc5; 2015-11-10T17:41:47+01:00)
Maven home: /Library/apache-maven-3.3.9/apache-maven-3.3.9
Java version: 1.8.0_91, vendor: Oracle Corporation
Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_91.jdk/Contents/Home/jre
Default locale: cs_CZ, platform encoding: UTF-8
OS name: "mac os x", version: "10.12.3", arch: "x86_64", family: "mac"
<project>
..
<properties>
<kotlin.version>1.1.2-2</kotlin.version>
</properties>
..
<dependencies>
..
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jre8</artifactId>
<version>${kotlin.version}</version>
</dependency>
..
</dependencies>
<build>
<plugins>
..
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<configuration>
<jvmTarget>1.8</jvmTarget>
<languageVersion>1.1</languageVersion>
<apiVersion>1.1</apiVersion>
</configuration>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/java</source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>process-test-sources</phase>
<goals>
<goal>test-compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/test/java</source>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
..
<plugins>
</build>
</project>
Error:Kotlin: Supertypes of the following classes cannot be resolved. Please make sure you have the required dependencies in the classpath:
class kotlin.reflect.KDeclarationContainer, unresolved supertypes: kotlin.Any
class kotlin.reflect.KAnnotatedElement, unresolved supertypes: kotlin.Any
class kotlin.reflect.KClassifier, unresolved supertypes: kotlin.Any