Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.NoClassDefFoundError #2732

Closed
Enderman-TPing opened this issue Jul 14, 2023 · 2 comments
Closed

java.lang.NoClassDefFoundError #2732

Enderman-TPing opened this issue Jul 14, 2023 · 2 comments
Labels
x:question 标签: 需要更多信息 z:invalid 状态: 无效问题

Comments

@Enderman-TPing
Copy link

问题描述

运行自己写的jar包,日志如下:

Exception in thread "main" java.lang.NoClassDefFoundError: net/mamoe/mirai/BotFactory
	at io.github.et.Main.main(Main.java:25)
Caused by: java.lang.ClassNotFoundException: net.mamoe.mirai.BotFactory
	at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
	at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
	at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
	... 1 more

复现

  • 按以下方式配置依赖:
plugins {
    id 'java'
    id 'org.jetbrains.kotlin.jvm' version '1.5.21'
}

group 'io.github.et'
version '4.0.0-pre1'

repositories {
    mavenCentral()
}

jar {
    manifest {
        attributes 'Main-Class': 'io.github.et.Main'
    }
}

dependencies {
    implementation 'net.sf.json-lib:json-lib:2.4:jdk15'
    implementation 'cn.hutool:hutool-all:5.8.11'
    implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.21'
    implementation 'io.github.fragland:MineStat:3.0.5'
    implementation 'net.mamoe:mirai-core:2.15.0'
    testImplementation 'org.junit.jupiter:junit-jupiter-api:5.8.1'
    testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.8.1'
}

sourceSets {
    main.kotlin.srcDirs += 'src/main/kotlin'
    main.java.srcDirs += 'src/main/java'
}

test {
    useJUnitPlatform()
}
  • gradle jar打包
  • java -jar运行

mirai-core 版本

2.15.0

bot-protocol

ANDROID_WATCH

其他组件版本

No response

系统日志

见上

网络日志

No response

补充信息

在打包过程中有警告;

警告: 未知的枚举常量 Kind.RESTRICTED_ABSTRACT_MESSAGE_KEYS
  原因: 找不到net.mamoe.mirai.console.compiler.common.ResolveContext$Kind的类文件
警告: 未知的枚举常量 Kind.RESTRICTED_ABSTRACT_MESSAGE_KEYS
2 个警告
@Enderman-TPing Enderman-TPing changed the title java.lang.NoClassDefError java.lang.NoClassDefFoundError Jul 14, 2023
@KKW557
Copy link

KKW557 commented Jul 14, 2023

-cp依赖库了吗

@Karlatemp
Copy link
Member

gradle 打包默认不会携带依赖,当然不能运行,你应该问搜索引擎

@Karlatemp Karlatemp closed this as not planned Won't fix, can't repro, duplicate, stale Jul 14, 2023
@Karlatemp Karlatemp added z:invalid 状态: 无效问题 x:question 标签: 需要更多信息 labels Jul 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
x:question 标签: 需要更多信息 z:invalid 状态: 无效问题
Projects
None yet
Development

No branches or pull requests

3 participants