MapDB ClassNotFoundException:kotlin.jvm.internal.Intrinsics [英] MapDB ClassNotFoundException: kotlin.jvm.internal.Intrinsics

查看:1263
本文介绍了MapDB ClassNotFoundException:kotlin.jvm.internal.Intrinsics的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行一个简单的mapdb示例,但是得到错误:

I am trying to run a simple mapdb example, but get the error:

    Exception in thread "main" java.lang.NoClassDefFoundError: kotlin/jvm/internal/Intrinsics
    at org.mapdb.DBMaker.fileDB(DBMaker.kt)
    at leechies.Truc.main(Truc.java:9)
Caused by: java.lang.ClassNotFoundException: kotlin.jvm.internal.Intrinsics
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 2 more

我的班级:

package leechies;
import java.util.concurrent.ConcurrentMap;

import org.mapdb.DB;
import org.mapdb.DBMaker;

public class Truc {
    public static void main(String[] args) {
        DB db = DBMaker.fileDB("file.db").make();
        ConcurrentMap map = db.hashMap("map").createOrOpen();
        map.put("something", "here");
        db.close();
    }
}

我的pomx.xml

My pomx.xml

<dependencies>
    <dependency>
        <groupId>org.mapdb</groupId>
        <artifactId>mapdb</artifactId>
        <version>3.0.3</version>
    </dependency>

我使用rigth click - > Run as ... - > java application。

I run with rigth click -> Run as... -> java application.

推荐答案

kotlin-runtime 必须在 classpath 并验证 $ echo $ CLASSPATH

或者您必须添加 kotlin-runtime 到maven然后在jar中自行组装 mvn编译程序集:单个

Or you have to add kotlin-runtime to maven and then assemble inside the jar itself with mvn compile assembly:single,

<dependency>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-runtime</artifactId>
    <version>1.1.3</version>
    <scope>compile</scope>
</dependency>

<dependency>
    <groupId>org.jetbrains.kotlin</groupId>
    <artifactId>kotlin-stdlib</artifactId>
    <version>1.1.3</version>
    <scope>compile</scope>
</dependency>

需要附加到工件上,可以使用程序集完成-plugin

which need to be attached to artifact as well and can be done with assembly-plugin.

    <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <configuration>
            <archive>
                <manifest>
                    <mainClass>event.handlers.InventoryEventHandler</mainClass>
                </manifest>
            </archive>
            <descriptorRefs>
                <descriptorRef>jar-with-dependencies</descriptorRef>
            </descriptorRefs>
        </configuration>
    </plugin>

你可以通过

$ jar -tf target/amz-wavelength-1.0-SNAPSHOT-jar-with-dependencies.jar | grep kotlin-runtime
META-INF/kotlin-runtime.kotlin_module

$ jar -tf target/amz-wavelength-1.0-SNAPSHOT-jar-with-dependencies.jar | grep "kotlin/jvm/internal/*"

这篇关于MapDB ClassNotFoundException:kotlin.jvm.internal.Intrinsics的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆