simple-robot / simbot-component-kook

一个 Kotlin 多平台的 KOOK(开黑啦) Bot SDK 实现库,一个 Simple Robot 组件库,Java 友好、异步高效~ ❤️‍🔥❤️‍🔥😘
https://simbot.forte.love/component-kook.html
GNU Lesser General Public License v3.0
19 stars 1 forks source link

3.0.0.0.preview.3.0 无法正常启动 #17

Closed HeilantG closed 2 years ago

HeilantG commented 2 years ago

版本:

        <dependency>
            <groupId>love.forte.simbot.boot</groupId>
            <artifactId>simboot-core</artifactId>
            <version>3.0.0.preview.8.0</version>
        </dependency>
        <dependency>
            <groupId>love.forte.simbot.component</groupId>
            <artifactId>simbot-component-kaiheila-boot</artifactId>
            <version>3.0.0.0.preview.3.0</version>
        </dependency>

问题描述: 无法正常启动开黑啦组件

启动问题:


Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2022-04-28 09:49:42.921 ERROR 11044 --- [           main] o.s.boot.SpringApplication               : Application run failed

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'runAndConfigSimbotContext' defined in love.forte.simboot.autoconfigure.SimbootAutoconfigure: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [love.forte.simboot.SimbootContext]: Factory method 'runAndConfigSimbotContext' threw exception; nested exception is love.forte.simboot.SimbootApplicationException: java.lang.AbstractMethodError: Receiver class love.forte.simboot.autoconfigure.SpringResourceBotVerifyInfo does not define or inherit an implementation of the resolved method 'abstract java.lang.String getComponentId()' of interface love.forte.simbot.BotVerifyInfo.
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:658) ~[spring-beans-5.3.18.jar:5.3.18]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:638) ~[spring-beans-5.3.18.jar:5.3.18]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1352) ~[spring-beans-5.3.18.jar:5.3.18]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1195) ~[spring-beans-5.3.18.jar:5.3.18]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:582) ~[spring-beans-5.3.18.jar:5.3.18]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:542) ~[spring-beans-5.3.18.jar:5.3.18]
    at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:335) ~[spring-beans-5.3.18.jar:5.3.18]
    at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:234) ~[spring-beans-5.3.18.jar:5.3.18]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:333) ~[spring-beans-5.3.18.jar:5.3.18]
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:208) ~[spring-beans-5.3.18.jar:5.3.18]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:953) ~[spring-beans-5.3.18.jar:5.3.18]
    at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:918) ~[spring-context-5.3.18.jar:5.3.18]
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:583) ~[spring-context-5.3.18.jar:5.3.18]
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:145) ~[spring-boot-2.6.6.jar:2.6.6]
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:740) ~[spring-boot-2.6.6.jar:2.6.6]
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:415) ~[spring-boot-2.6.6.jar:2.6.6]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:303) ~[spring-boot-2.6.6.jar:2.6.6]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1312) ~[spring-boot-2.6.6.jar:2.6.6]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1301) ~[spring-boot-2.6.6.jar:2.6.6]
    at com.catcraft.tyche.khl.KhlBotRunApplication.main(KhlBotRunApplication.java:11) ~[classes/:na]
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [love.forte.simboot.SimbootContext]: Factory method 'runAndConfigSimbotContext' threw exception; nested exception is love.forte.simboot.SimbootApplicationException: java.lang.AbstractMethodError: Receiver class love.forte.simboot.autoconfigure.SpringResourceBotVerifyInfo does not define or inherit an implementation of the resolved method 'abstract java.lang.String getComponentId()' of interface love.forte.simbot.BotVerifyInfo.
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:185) ~[spring-beans-5.3.18.jar:5.3.18]
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:653) ~[spring-beans-5.3.18.jar:5.3.18]
    ... 19 common frames omitted
Caused by: love.forte.simboot.SimbootApplicationException: java.lang.AbstractMethodError: Receiver class love.forte.simboot.autoconfigure.SpringResourceBotVerifyInfo does not define or inherit an implementation of the resolved method 'abstract java.lang.String getComponentId()' of interface love.forte.simbot.BotVerifyInfo.
    at love.forte.simboot.SimbootApp.run(SimbootApp.kt:75) ~[simboot-api-3.0.0.preview.8.0.jar:na]
    at love.forte.simboot.autoconfigure.DefaultSimbootAppRunner.run(SimbootAppRunnerConfiguration.kt:49) ~[simboot-core-spring-boot-starter-3.0.0.preview.7.0.jar:na]
    at love.forte.simboot.autoconfigure.SimbootAutoconfigure.runAndConfigSimbotContext(SimbootAutoconfigure.kt:45) ~[simboot-core-spring-boot-starter-3.0.0.preview.7.0.jar:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
    at java.base/java.lang.reflect.Method.invoke(Method.java:566) ~[na:na]
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:154) ~[spring-beans-5.3.18.jar:5.3.18]
    ... 20 common frames omitted
Caused by: java.lang.AbstractMethodError: Receiver class love.forte.simboot.autoconfigure.SpringResourceBotVerifyInfo does not define or inherit an implementation of the resolved method 'abstract java.lang.String getComponentId()' of interface love.forte.simbot.BotVerifyInfo.
    at love.forte.simbot.component.kaiheila.KaiheilaBotManager.register(KaiheilaBotManager.kt:50) ~[simbot-component-kaiheila-core-3.0.0.0.preview.3.0.jar:na]
    at love.forte.simbot.component.kaiheila.KaiheilaBotManager.register(KaiheilaBotManager.kt:38) ~[simbot-component-kaiheila-core-3.0.0.0.preview.3.0.jar:na]
    at love.forte.simboot.core.CoreBootEntrance.run0(CoreBootEntrance.kt:231) ~[simboot-core-3.0.0.preview.8.0.jar:na]
    at love.forte.simboot.core.CoreBootEntrance.run(CoreBootEntrance.kt:127) ~[simboot-core-3.0.0.preview.8.0.jar:na]
    at love.forte.simboot.SimbootApp.run(SimbootApp.kt:73) ~[simboot-api-3.0.0.preview.8.0.jar:na]
    ... 27 common frames omitted

进程已结束,退出代码1
ForteScarlet commented 2 years ago

at love.forte.simboot.autoconfigure.DefaultSimbootAppRunner.run(SimbootAppRunnerConfiguration.kt:49) ~[simboot-core-spring-boot-starter-3.0.0.preview.7.0.jar:na]

环境中的 simboot-core-spring-boot-starter 似乎还是 v3.0.0.preview.7.0 版本,确认是否手动导入了此版本的依赖。如果有,尝试更正版本到 v3.0.0.preview.8.0

HeilantG commented 2 years ago

以确认版本为8.0 出现新的错误 , bot无法启动


An attempt was made to call a method that does not exist. The attempt was made from the following location:

    io.ktor.client.utils.CoroutineDispatcherUtilsKt.clientDispatcher(CoroutineDispatcherUtils.kt:22)

The following method did not exist:

    'kotlinx.coroutines.CoroutineDispatcher kotlinx.coroutines.CoroutineDispatcher.limitedParallelism(int)'

The calling method's class, io.ktor.client.utils.CoroutineDispatcherUtilsKt, was loaded from the following location:

    jar:file:/C:/Users/HeilantG/.m2/repository/io/ktor/ktor-client-core-jvm/2.0.0/ktor-client-core-jvm-2.0.0.jar!/io/ktor/client/utils/CoroutineDispatcherUtilsKt.class

The called method's class, kotlinx.coroutines.CoroutineDispatcher, is available from the following locations:

    jar:file:/C:/Users/HeilantG/.m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.5.2/kotlinx-coroutines-core-jvm-1.5.2.jar!/kotlinx/coroutines/CoroutineDispatcher.class

The called method's class hierarchy was loaded from the following locations:

    kotlinx.coroutines.CoroutineDispatcher: file:/C:/Users/HeilantG/.m2/repository/org/jetbrains/kotlinx/kotlinx-coroutines-core-jvm/1.5.2/kotlinx-coroutines-core-jvm-1.5.2.jar
    kotlin.coroutines.AbstractCoroutineContextElement: file:/C:/Users/HeilantG/.m2/repository/org/jetbrains/kotlin/kotlin-stdlib/1.6.10/kotlin-stdlib-1.6.10.jar

Action:

Correct the classpath of your application so that it contains compatible versions of the classes io.ktor.client.utils.CoroutineDispatcherUtilsKt and kotlinx.coroutines.CoroutineDispatcher

进程已结束,退出代码1
ForteScarlet commented 2 years ago

临时解决办法:

<properties>
        <java.version>1.8</java.version>
        <kotlinx-coroutines.version>1.6.1</kotlinx-coroutines.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.jetbrains.kotlinx</groupId>
            <artifactId>kotlinx-coroutines-core-jvm</artifactId>
            <version>${kotlinx-coroutines.version}</version>
        </dependency>

        <dependency>
            <groupId>love.forte.simbot.boot</groupId>
            <artifactId>simboot-core-spring-boot-starter</artifactId>
            <version>3.0.0.preview.8.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.jetbrains.kotlinx</groupId>
                    <artifactId>kotlinx-coroutines-core-jvm</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>love.forte.simbot.component</groupId>
            <artifactId>simbot-component-kaiheila-boot</artifactId>
            <version>3.0.0.0.preview.3.0</version>
            <exclusions>
                <exclusion>
                    <groupId>org.jetbrains.kotlinx</groupId>
                    <artifactId>kotlinx-coroutines-core-jvm</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
       .....
    </dependencies>

但是这只能保证正常启动,无法监听事件,原因参考 #18

ForteScarlet commented 2 years ago

https://github.com/simple-robot/simbot-component-kaiheila/releases/tag/v3.0.0.0.preview.3.1