更新时间:2022-05-10 03:10:43
确保在你的 pom.xml
Make sure you have this declaration in <build>
of your pom.xml
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>process-sources</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/java</source>
<source>src/main/kotlin</source>
<source>src/main/resources</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>
<source>src/test/kotlin</source>
<source>src/test/resources</source>
</sourceDirs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
确保配置中提到的所有文件夹(src/main 中的 3x & src/test 中的 3x)实际存在,即使它们不包含任何课程/资源.一旦配置适合您,您仍然可以对其进行微调.
Make sure that all folders (3x in src/main & 3x in src/test) mentioned in the configuration actually exist, even if they don’t contain any classes/resources. You can still fine-tune the configuration once it works for you.
还要注意使用我上面提到的完全相同的顺序让编译器先编译Java代码.
Also pay attention to use exactly the same order I mentioned above to let the compiler compile the Java code first.