Kotlin使用JDK模块

时间:2018-12-20 09:26:27

标签: java kotlin smartcardio

我目前正在编写使用Java库(由我开发)的Kotlin代码,该库使用#ifndef _MSC_VER # include <cxxabi.h> #endif #include <memory> #include <string> #include <cstdlib> template <class T> std::string type_name() { typedef typename std::remove_reference<T>::type TR; std::unique_ptr<char, void(*)(void*)> own ( #ifndef _MSC_VER abi::__cxa_demangle(typeid(TR).name(), nullptr, nullptr, nullptr), #else nullptr, #endif std::free ); std::string r = own != nullptr ? own.get() : typeid(TR).name(); if (std::is_const<TR>::value) r += " const"; if (std::is_volatile<TR>::value) r += " volatile"; if (std::is_lvalue_reference<T>::value) r += "&"; else if (std::is_rvalue_reference<T>::value) r += "&&"; return r; } lib,但是在Kotlin编译时显示以下错误:

javax.smartcardio

该怎么办?

谢谢。

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

Cannot access class 'javax.smartcardio.CommandAPDU'. Check your module classpath for missing or conflicting dependencies

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

1 个答案:

答案 0 :(得分:1)

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

您始终可以通过在项目中显式声明hte依赖关系来对其进行修复。