kotlin getparameters函数不起作用

时间:2018-11-01 06:01:30

标签: kotlin compiler-errors kotlinx.coroutines

我不断得到:

java.lang.IllegalStateException: Resource not found in classpath: kotlin/coroutines/coroutines.kotlin_builtins

在下面的示例中,我尝试获取任何对象的参数作为指针:

::flagDbInfo.parameters

我向我的maven添加了以下依赖项:

<dependency>
    <groupId>org.jetbrains.kotlinx</groupId>
    <artifactId>kotlinx-coroutines-core</artifactId>
    <version>0.30.2</version>
</dependency>

<dependency>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-reflect</artifactId>
    <version>1.3.0</version>
</dependency>

2 个答案:

答案 0 :(得分:3)

由于您使用的是1.3.0版,因此我建议以下依赖项

    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-reflect</artifactId>
        <version>1.3.0</version>
    </dependency>
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib</artifactId>
        <version>1.3.0</version>
    </dependency>

答案 1 :(得分:1)

使用IntelliJ 2019.1,kotlin 1.3.30在Spring Boot应用程序上工作时遇到相同的错误。 以下配置(在pom.xml中)对其进行了修复:

<dependencies>
... (your other dependencies)
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-stdlib</artifactId>
        <version>1.3.30</version>
    </dependency>
    <dependency>
        <groupId>org.jetbrains.kotlin</groupId>
        <artifactId>kotlin-reflect</artifactId>
        <version>1.3.30</version>
    </dependency>
</dependencies>
...
<plugins>
...
<plugin>
            <artifactId>kotlin-maven-plugin</artifactId>
            <groupId>org.jetbrains.kotlin</groupId>
            <version>1.3.30</version>
            <configuration>
                <args>
                    <arg>-Xjsr305=strict</arg>
                </args>
                <jvmTarget>1.8</jvmTarget>
            </configuration>
            <executions>
                <execution>
                    <id>compile</id>
                    <phase>compile</phase>
                    <goals> <goal>compile</goal> </goals>
                    <configuration>
                        <sourceDirs>
                            <source>src/main/java</source>
                            <source>src/main/kotlin</source>
                        </sourceDirs>
                    </configuration>
                </execution>
                <execution>
                    <id>test-compile</id>
                    <phase>test-compile</phase>
                    <goals> <goal>test-compile</goal> </goals>
                </execution>
            </executions>
        </plugin>
...
</plugins>

此外,我最初也将kotlin-stdlib-jdk8工件作为依赖项,但是如果包含kotlin-stdlib工件,则不需要jdk8。有关更多详细信息,请参见https://kotlinlang.org/docs/reference/whatsnew12.html#kotlin-standard-library-artifacts-and-split-packages