gpt4 book ai didi

java - Kotlin 使用 JDK 模块

转载 作者:行者123 更新时间:2023-12-02 10:27:08 25 4
gpt4 key购买 nike

我目前正在编写使用 Java 库(由我开发)的 Kotlin 代码,该库使用 javax.smartcardio lib,但在 Kotlin 编译时显示以下错误:

无法访问类“javax.smartcardio.CommandAPDU”。检查模块类路径是否缺少或冲突的依赖项

我该如何解决这个问题?

谢谢。

编辑:我正在使用 Maven,我的依赖项和插件如下:

<properties>
<kotlin.version>1.3.11</kotlin.version>
</properties>


<dependencies>
<dependency>
<groupId>io.javalin</groupId>
<artifactId>javalin</artifactId>
<version>2.4.0</version>
</dependency>

<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.25</version>
</dependency>

<!-- Kotlin -->
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin.version}</version>
</dependency>

<dependency>
<groupId>my.project</groupId>
<artifactId>apdu-processor</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>

</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
</execution>
<execution>
<id>testCompile</id>
<phase>test-compile</phase>
<goals>
<goal>testCompile</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>

使用javax.smartcardio的库是apdu-processor

最佳答案

由于 javax.smartcardio 不是项目的直接依赖项,因此需要从 apdu-processor 传递声明。您必须确保此依赖项被声明为COMPILE依赖项,而不是PROVIDED,也不是RUNTIME

您始终可以通过在项目中显式声明 hte 依赖项来修复它。

关于java - Kotlin 使用 JDK 模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53865724/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com