kotlin getparameters功能不起作用

问题描述 投票:2回答:2

我不断得到:

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

虽然我尝试在下面的示例中获取任何对象的参数作为pointet:

::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>
kotlin compiler-errors kotlinx.coroutines
2个回答
4
投票

由于您使用的是版本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>

2
投票

使用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

© www.soinside.com 2019 - 2024. All rights reserved.