project-mirai / mirai-console-plugin-template

Template for Mirai Console plugins
GNU Affero General Public License v3.0
67 stars 17 forks source link

类加载器问题?初始化插件提示找不到 #23

Closed Shizoukia closed 2 months ago

Shizoukia commented 2 months ago
net.mamoe.mirai.console.internal.util.ServiceLoadException: Could not load service net.miaomoe.mirai.ATRICOREMirai.
        at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadService(PluginServiceHelper.kt:62)
        at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadAllServices(PluginServiceHelper.kt:44)
        at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl$extractPlugins$findAllInstances$1.invoke(BuiltInJvmPluginLoaderImpl.kt:205)
        at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl$extractPlugins$findAllInstances$1.invoke(BuiltInJvmPluginLoaderImpl.kt:200)
        at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
        at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:314)
        at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:303)
        at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:214)
        at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:316)
        at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:303)
        at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:214)
        at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:214)
        at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:787)
        at kotlin.sequences.SequencesKt___SequencesKt.toSet(_Sequences.kt:828)
        at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.extractPlugins(BuiltInJvmPluginLoaderImpl.kt:287)
        at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.listPlugins(BuiltInJvmPluginLoaderImpl.kt:72)
        at net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader$BuiltIn.listPlugins(JvmPluginLoader.kt)
        at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.listAndSortAllPlugins(PluginManagerImpl.kt:207)
        at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.findAndSortAllPluginsUsingBuiltInLoaders(PluginManagerImpl.kt:153)
        at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.loadAllPluginsUsingBuiltInLoaders$mirai_console(PluginManagerImpl.kt:163)
        at net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge.doStart$mirai_console(MiraiConsoleImplementationBridge.kt:303)
        at net.mamoe.mirai.console.MiraiConsoleImplementation$Companion.start(MiraiConsoleImplementation.kt:512)
        at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon(MiraiConsoleTerminalLoader.kt:182)
        at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon$default(MiraiConsoleTerminalLoader.kt:181)
        at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.main(MiraiConsoleTerminalLoader.kt:59)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.base/java.lang.reflect.Method.invoke(Method.java:568)
        at org.itxtech.mcl.Utility.bootJars(Utility.java:86)
        at org.itxtech.mcl.Utility.bootJars(Utility.java:76)
        at org.itxtech.mcl.Utility.bootMirai(Utility.java:98)
        at org.itxtech.mcl.module.builtin.Boot.boot(Boot.java:113)
        at org.itxtech.mcl.module.ModuleManager.phaseBoot(ModuleManager.java:123)
        at org.itxtech.mcl.Loader.lambda$start$4(Loader.java:196)
        at org.itxtech.mcl.Loader.tryCatching(Loader.java:151)
        at org.itxtech.mcl.Loader.start(Loader.java:196)
        at org.itxtech.mcl.Loader.main(Loader.java:84)
Caused by: java.lang.NoClassDefFoundError: redis/clients/jedis/JedisPubSub
        at java.base/java.lang.Class.forName0(Native Method)
        at java.base/java.lang.Class.forName(Class.java:467)
        at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadService(PluginServiceHelper.kt:53)
        ... 37 more
Caused by: java.lang.ClassNotFoundException: redis.clients.jedis.JedisPubSub
        at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:592)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:525)
        at net.mamoe.mirai.console.internal.plugin.JvmPluginClassLoaderN.loadClass(JvmPluginClassLoader.kt:503)
        ... 40 more
plugins {
    val kotlinVersion = "1.6.10"
    kotlin("jvm") version kotlinVersion
    kotlin("plugin.serialization") version kotlinVersion
    id("com.github.johnrengelman.shadow") version "7.0.0"
    id("net.mamoe.mirai-console") version "2.13.2"
}

group = "org.example"
version = "0.1.0"

repositories {
    if (System.getenv("CI")?.toBoolean() != true) {
        maven("https://maven.aliyun.com/repository/central") // 阿里云国内代理仓库
    }
    mavenCentral()
}
dependencies {
    implementation("redis.clients:jedis:2.9.0")
    compileOnly("com.google.code.gson:gson:2.10.1")
    implementation("org.json:json:20231013")
    implementation("mysql:mysql-connector-java:8.0.25")
    implementation("org.mongodb:mongo-java-driver:3.8.2")
    compileOnly("org.projectlombok:lombok:1.18.28")
    annotationProcessor("org.projectlombok:lombok:1.18.28")
}//

这个是jar内的dependstxt文件的内容

com.google.protobuf:protobuf-java:3.11.4
mysql:mysql-connector-java:8.0.25
org.apache.commons:commons-pool2:2.4.2
org.jetbrains.kotlin:kotlin-stdlib-common:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.10
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.10
org.jetbrains.kotlin:kotlin-stdlib:1.6.10
org.jetbrains:annotations:13.0
org.json:json:20231013
org.mongodb:mongo-java-driver:3.8.2
redis.clients:jedis:2.9.0

有没有大佬知道怎么回事

Shizoukia commented 2 months ago

已自行解决 我不能直接在onenable去初始化某个类 否则百分百出问题