Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 创建和发布Kotlin库以避免多次运行时问题的正确方法是什么?_Java_Maven_Kotlin - Fatal编程技术网

Java 创建和发布Kotlin库以避免多次运行时问题的正确方法是什么?

Java 创建和发布Kotlin库以避免多次运行时问题的正确方法是什么?,java,maven,kotlin,Java,Maven,Kotlin,我有一个Kotlin库,我想发布到Maven存储库并在其他应用程序中使用 但当我在Kotlin应用程序中将其作为依赖项添加(到pom.xml)时,我得到以下警告: [WARNING] Some JAR files in the classpath have the Kotlin Runtime library bundled into them. This may cause difficult to debug problems if there's a different version o

我有一个Kotlin库,我想发布到Maven存储库并在其他应用程序中使用

但当我在Kotlin应用程序中将其作为依赖项添加(到
pom.xml
)时,我得到以下警告:

[WARNING] Some JAR files in the classpath have the Kotlin Runtime library bundled into them.
This may cause difficult to debug problems if there's a different version of the
Kotlin Runtime library in the classpath. Consider removing these libraries from the classpath
or use '-Xskip-runtime-version-check' to suppress this warning
[WARNING] .........mylib.jar: (-1, -1) Library has Kotlin runtime bundled into it

这是什么意思?我是否需要从我的库JAR中排除
kotlin stdlib
?但如果我也想在Java应用程序中使用它呢?

结果表明,这只是我的库项目特有的问题

我使用
maven shade plugin
生成了一个“胖”JAR(包含所有依赖项),它取代了原来的JAR(因此我部署了所有绑定的依赖项,而不仅仅是库本身和依赖项列表),因为它还打算用作一个简单的控制台应用程序


因此,解决方案是要么将应用程序移动到单独的项目,要么保留原始JAR(在插件配置中使用
+
),和/或在部署过程中使用Maven配置文件禁用此插件,如下所述。

我在Kotlin应用程序中遇到了类似的问题。当我从导入的胖jar中排除kotlin stdlib库时,问题就消失了。如果在Java应用程序中使用fat jar,则不要排除依赖项。

可能相关:您是否尝试在库的pom中将
kotlin stdlib
指定为
提供的
依赖项?理论上,这应该允许与Kotlin兼容,但将其从构建包中排除。