同时引入kook组件库和mirai库时会提示无法解析miraiBot #188
-
涉及的编程语言Java 涉及的组件库KOOK, mirai 疑问描述是无法在一个项目中同时引入kook和mirai么?在仅引入kook组件库的情况下项目可以正常运行。 <!-- simbot4核心库 -->
<dependency>
<groupId>love.forte.simbot</groupId>
<artifactId>simbot-core-spring-boot-starter</artifactId>
<version>4.0.0-beta3</version>
</dependency>
<!-- KOOK组件库 -->
<dependency>
<groupId>love.forte.simbot.component</groupId>
<artifactId>simbot-component-kook-core-jvm</artifactId>
<version>4.0.0-beta2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.ktor/ktor-client-java-jvm -->
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-java-jvm</artifactId>
<version>2.3.10</version>
<scope>runtime</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/net.mamoe/mirai-core-jvm-->
<dependency>
<groupId>love.forte.simbot.component</groupId>
<artifactId>simbot-component-mirai-core</artifactId>
<version>3.2.0.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.ktor/ktor-client-okhttp-jvm -->
<dependency>
<groupId>io.ktor</groupId>
<artifactId>ktor-client-okhttp-jvm</artifactId>
<version>2.3.10</version>
<scope>runtime</scope>
</dependency> love.forte.simbot.spring.common.BotConfigResourceLoadOnFailureException: JSON resource [file [D:\JavaProject\kkbot\target\classes\simbot-bots\qqbot.bot.json]] fails to deserialize, and this may be because a component does not support polymorphic configurations, e.g. the configuration class does not implement class love.forte.simbot.bot.SerializableBotConfiguration, the component does not provide polymorphic serialisation information, etc. The information: Unexpected JSON token at offset 0: Serializer for subclass 'simbot.mirai' is not found in the polymorphic scope of 'SerializableBotConfiguration' at path: $
Check if class with serial name 'simbot.mirai' exists and serializer is registered in a corresponding SerializersModule.
To be registered automatically, class 'simbot.mirai' has to be '@Serializable', and the base class 'SerializableBotConfiguration' has to be sealed and '@Serializable'.
JSON input: {
"component": "simbot.mirai",
"code": "123456789",
"authorization": {
"type": "qr_code"
}
}
at love.forte.simbot.spring.configuration.application.BotAutoLoader.processDecodeFailure(DefaultSimbotApplicationProcessor.kt:294) ~[simbot-core-spring-boot-starter-4.0.0-beta3.jar:na]
at love.forte.simbot.spring.configuration.application.BotAutoLoader.access$processDecodeFailure(DefaultSimbotApplicationProcessor.kt:135) ~[simbot-core-spring-boot-starter-4.0.0-beta3.jar:na]
at love.forte.simbot.spring.configuration.application.BotAutoLoader$load$botList$2.invoke(DefaultSimbotApplicationProcessor.kt:189) ~[simbot-core-spring-boot-starter-4.0.0-beta3.jar:na]
at love.forte.simbot.spring.configuration.application.BotAutoLoader$load$botList$2.invoke(DefaultSimbotApplicationProcessor.kt:177) ~[simbot-core-spring-boot-starter-4.0.0-beta3.jar:na]
at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210) ~[kotlin-stdlib-1.9.23.jar:1.9.23-release-779]
at kotlin.sequences.FilteringSequence$iterator$1.calcNext(Sequences.kt:170) ~[kotlin-stdlib-1.9.23.jar:1.9.23-release-779]
at kotlin.sequences.FilteringSequence$iterator$1.hasNext(Sequences.kt:194) ~[kotlin-stdlib-1.9.23.jar:1.9.23-release-779]
at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:214) ~[kotlin-stdlib-1.9.23.jar:1.9.23-release-779]
at kotlin.sequences.SequencesKt___SequencesKt.toList(_Sequences.kt:816) ~[kotlin-stdlib-1.9.23.jar:1.9.23-release-779]
at love.forte.simbot.spring.configuration.application.BotAutoLoader.load(DefaultSimbotApplicationProcessor.kt:225) ~[simbot-core-spring-boot-starter-4.0.0-beta3.jar:na]
at love.forte.simbot.spring.configuration.application.DefaultSimbotApplicationProcessor.loadBots(DefaultSimbotApplicationProcessor.kt:125) ~[simbot-core-spring-boot-starter-4.0.0-beta3.jar:na]
at love.forte.simbot.spring.configuration.application.DefaultSimbotApplicationProcessor.process0(DefaultSimbotApplicationProcessor.kt:121) ~[simbot-core-spring-boot-starter-4.0.0-beta3.jar:na]
at love.forte.simbot.spring.configuration.application.DefaultSimbotApplicationProcessor.process(DefaultSimbotApplicationProcessor.kt:110) ~[simbot-core-spring-boot-starter-4.0.0-beta3.jar:na]
at love.forte.simbot.spring.configuration.application.SimbotApplicationRunner.run(SimbotApplicationRunner.kt:56) ~[simbot-core-spring-boot-starter-4.0.0-beta3.jar:na]
at org.springframework.boot.SpringApplication.lambda$callRunner$4(SpringApplication.java:786) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.util.function.ThrowingConsumer$1.acceptWithException(ThrowingConsumer.java:83) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.util.function.ThrowingConsumer.accept(ThrowingConsumer.java:60) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.util.function.ThrowingConsumer$1.accept(ThrowingConsumer.java:88) ~[spring-core-6.1.5.jar:6.1.5]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:798) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:786) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.lambda$callRunners$3(SpringApplication.java:774) ~[spring-boot-3.2.4.jar:3.2.4]
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:na]
at java.base/java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:357) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:510) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[na:na]
at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[na:na]
at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596) ~[na:na]
at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:774) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:341) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1354) ~[spring-boot-3.2.4.jar:3.2.4]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1343) ~[spring-boot-3.2.4.jar:3.2.4]
at com.gyyst.kkbot.KkbotApplication.main(KkbotApplication.java:23) ~[classes/:na]
Caused by: kotlinx.serialization.json.internal.JsonDecodingException: Unexpected JSON token at offset 0: Serializer for subclass 'simbot.mirai' is not found in the polymorphic scope of 'SerializableBotConfiguration' at path: $
Check if class with serial name 'simbot.mirai' exists and serializer is registered in a corresponding SerializersModule.
To be registered automatically, class 'simbot.mirai' has to be '@Serializable', and the base class 'SerializableBotConfiguration' has to be sealed and '@Serializable'.
JSON input: {
"component": "simbot.mirai",
"code": "123456789",
"authorization": {
"type": "qr_code"
}
}
at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:24) ~[kotlinx-serialization-json-jvm-1.6.3.jar:na]
at kotlinx.serialization.json.internal.JsonExceptionsKt.JsonDecodingException(JsonExceptions.kt:32) ~[kotlinx-serialization-json-jvm-1.6.3.jar:na]
at kotlinx.serialization.json.internal.AbstractJsonLexer.fail(AbstractJsonLexer.kt:598) ~[kotlinx-serialization-json-jvm-1.6.3.jar:na]
at kotlinx.serialization.json.internal.AbstractJsonLexer.fail$default(AbstractJsonLexer.kt:596) ~[kotlinx-serialization-json-jvm-1.6.3.jar:na]
at kotlinx.serialization.json.internal.StreamingJsonDecoder.decodeSerializableValue(StreamingJsonDecoder.kt:85) ~[kotlinx-serialization-json-jvm-1.6.3.jar:na]
at kotlinx.serialization.json.Json.decodeFromString(Json.kt:107) ~[kotlinx-serialization-json-jvm-1.6.3.jar:na]
at love.forte.simbot.spring.configuration.application.BotAutoLoader$load$botList$2.invoke(DefaultSimbotApplicationProcessor.kt:187) ~[simbot-core-spring-boot-starter-4.0.0-beta3.jar:na]
... 31 common frames omitted
|
Beta Was this translation helpful? Give feedback.
Answered by
ForteScarlet
Apr 12, 2024
Replies: 1 comment
-
mirai仅支持 simbot3,但是这里你使用了 simbot4,它们之间是不兼容的。kook应该也有 simbot3 的版本,可以在 releases 列表里找找。 不过mirai已经算是停止更新了(虽然现在还是有概率可以使用),这也是为什么它没有跟进 simbot4。后续可以考虑在simbot4的基础上切换到 kritor组件 上(目前此协议尚未稳定,暂不可用) 或者更稳妥的办法就是mirai组件和其他simbot4的组件分为不同的模块单独写。 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
gyyst
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
mirai仅支持 simbot3,但是这里你使用了 simbot4,它们之间是不兼容的。kook应该也有 simbot3 的版本,可以在 releases 列表里找找。
不过mirai已经算是停止更新了(虽然现在还是有概率可以使用),这也是为什么它没有跟进 simbot4。后续可以考虑在simbot4的基础上切换到 kritor组件 上(目前此协议尚未稳定,暂不可用)
或者更稳妥的办法就是mirai组件和其他simbot4的组件分为不同的模块单独写。