simple-robot / simpler-robot

Simple Robot,一个bot风格的高效异步事件调度框架 / A Bot-style event scheduling framework, asynchronous and high-performance
https://simbot.forte.love
GNU Lesser General Public License v3.0
510 stars 43 forks source link

读取bot配置文件失败 #624

Closed Enderman-TPing closed 1 year ago

Enderman-TPing commented 1 year ago

版本号

v3.0.0-RC.3

附加版本

     <dependency>
            <groupId>love.forte.simbot.boot</groupId>
            <artifactId>simboot-core-spring-boot-starter</artifactId>
            <version>${simbot.version}</version>
        </dependency>
        <!--        mirai组件-->
        <dependency>
            <groupId>love.forte.simbot.component</groupId>
            <artifactId>simbot-component-mirai-core</artifactId>
            <version>${simbot-mirai.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>love.forte.simbot</groupId>
                    <artifactId>simbot-logger</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

涉及的编程语言

Kotlin

项目构建工具

Maven

涉及的组件库

mirai (QQ)

问题描述

无法找到配置文件中的component,详见日志

复现方式

bot配置文件:

{
    "component": "simbot.mirai",
    "code": Your Code,
    "passwordInfo": {
        "type": "text",
        "text": "Your Password"
    },
    "config":{
        "protocol": "MACOS",
        "deviceInfo": {
            "type": "auto"
        }
    }
}

文件以spring boot打包:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.5</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.bot.qbot</groupId>
    <artifactId>QBot</artifactId>
    <version>3.3.0</version>

    <properties>
        <java.version>17</java.version>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <simbot.version>3.0.0-RC.3</simbot.version>
        <simbot-mirai.version>3.0.0.0-RC</simbot-mirai.version>
        <kotlin.version>1.8.0</kotlin.version>
    </properties>

    <dependencies>
        <!--simboot核心标准库-->
        <dependency>
            <groupId>love.forte.simbot.boot</groupId>
            <artifactId>simboot-core-spring-boot-starter</artifactId>
            <version>${simbot.version}</version>
        </dependency>
        <!--        mirai组件-->
        <dependency>
            <groupId>love.forte.simbot.component</groupId>
            <artifactId>simbot-component-mirai-core</artifactId>
            <version>${simbot-mirai.version}</version>
            <exclusions>
                <exclusion>
                    <groupId>love.forte.simbot</groupId>
                    <artifactId>simbot-logger</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>net.sf.json-lib</groupId>
            <artifactId>json-lib</artifactId>
            <version>2.1</version>
            <classifier>jdk15</classifier>
        </dependency>
        <dependency>
            <groupId>io.github.fragland</groupId>
            <artifactId>MineStat</artifactId>
            <version>3.0.5</version>
        </dependency>
        <dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.8.11</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-aop</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>druid-spring-boot-starter</artifactId>
            <version>1.2.9</version>
        </dependency>

        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-reflect</artifactId>
        </dependency>
        <dependency>
            <groupId>org.jetbrains.kotlin</groupId>
            <artifactId>kotlin-stdlib-jdk8</artifactId>
        </dependency>

    </dependencies>

    <build>
        <sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>2.6.7</version>
                <configuration>
                    <excludes>
                        <exclude>
                            <groupId>org.projectlombok</groupId>
                            <artifactId>lombok</artifactId>
                        </exclude>
                    </excludes>
                    <fork>true</fork>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jetbrains.kotlin</groupId>
                <artifactId>kotlin-maven-plugin</artifactId>
                <version>${kotlin.version}</version>
                <configuration>
                    <args>
                        <arg>-Xjsr305=strict</arg>
                    </args>
                    <compilerPlugins>
                        <plugin>spring</plugin>
                    </compilerPlugins>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.jetbrains.kotlin</groupId>
                        <artifactId>kotlin-maven-allopen</artifactId>
                        <version>${kotlin.version}</version>
                    </dependency>
                </dependencies>
            </plugin>
        </plugins>
    </build>

</project>

该问题只存在于打包成的jar文件

相关日志

02:55:49.107 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Building components...
02:55:49.108 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - There are no installed components. Try to find and install all component factories in current environment.
02:55:49.262 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Components are built: [MiraiComponent(id=simbot.mirai)]
02:55:49.263 [main] INFO love.forte.simbot.application.ApplicationConfiguration - The size of components built is 1
02:55:49.263 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Creating boot environment...
02:55:49.263 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Boot environment created: love.forte.simboot.core.application.BootEnvironment@5aebe890
02:55:49.264 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Initialize the bean container builder
02:55:49.264 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Scan packages [com.bot.qbot] for bean
02:55:49.265 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Building bean container by builder: love.forte.simboot.core.application.BeanContainerBuilderImpl@385e9564
02:55:49.282 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.SimbotExampleApplicationKt] is not PUBLIC and will be skipped.
02:55:49.291 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.Accepter.private$acceptRequest$1] is not PUBLIC and will be skipped.
02:55:49.294 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.Accepter.group$Accept$1] is not PUBLIC and will be skipped.
02:55:49.298 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.events.MemberChange$tellIncrease$1] is not PUBLIC and will be skipped.
02:55:49.302 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.events.TooLongMsgEvent$tooLong$1] is not PUBLIC and will be skipped.
02:55:49.302 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.events.MemberChange$haveJoined$1] is not PUBLIC and will be skipped.
02:55:49.304 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.events.MemberChange$tellDecrease$1] is not PUBLIC and will be skipped.
02:55:49.305 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.events.MemberChange$haveLeft$1] is not PUBLIC and will be skipped.
02:55:49.309 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.chatter.Public$chat$1] is not PUBLIC and will be skipped.
02:55:49.309 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.chatter.Public$chat$2] is not PUBLIC and will be skipped.
02:55:49.310 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.chatter.Private$privateReply$1] is not PUBLIC and will be skipped.
02:55:49.311 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.chatter.Public$MC$1] is not PUBLIC and will be skipped.
02:55:49.311 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.chatter.Public$MCServerStat$1] is not PUBLIC and will be skipped.
02:55:49.312 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.chatter.Private$beCalled$1] is not PUBLIC and will be skipped.
02:55:49.312 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.chatter.Private$to$1] is not PUBLIC and will be skipped.
02:55:49.312 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.chatter.Public$plusOne$1] is not PUBLIC and will be skipped.
02:55:49.314 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.chatter.Private$MCServerStat$1] is not PUBLIC and will be skipped.
02:55:49.314 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.chatter.Private$MC$1] is not PUBLIC and will be skipped.
02:55:49.315 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.chatter.Public$beCalled$1] is not PUBLIC and will be skipped.
02:55:49.316 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.chatter.Public$to$1] is not PUBLIC and will be skipped.
02:55:49.319 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.requests.GroupRequests$admin$1] is not PUBLIC and will be skipped.
02:55:49.319 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.requests.GroupRequests$title$1] is not PUBLIC and will be skipped.
02:55:49.322 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.msgCounts.MsgCounts$msgCountGroup$1] is not PUBLIC and will be skipped.
02:55:49.322 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.mainListeners.msgCounts.MsgCounts$msgCountPrivate$1] is not PUBLIC and will be skipped.
02:55:49.323 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.SimbotExampleApplicationKt$main$1] is not PUBLIC and will be skipped.
02:55:49.323 [main] WARN love.forte.simbot.application.ApplicationConfiguration - The visibility of kClass [class com.bot.qbot.SimbotExampleApplicationKt$main$2] is not PUBLIC and will be skipped.
02:55:49.323 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Bean container is built: love.forte.di.core.internal.CoreBeanManagerImpl@2beee7ff, The size of beans: 0
02:55:49.327 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Building listener manager...
02:55:49.330 [main] INFO love.forte.simbot.application.ApplicationConfiguration - The size of resolved event listeners is 0
02:55:49.330 [main] INFO love.forte.simbot.application.ApplicationConfiguration - The size of resolved Top-Level event listeners is 0
02:55:49.334 [main] DEBUG love.forte.simbot.core.event.SimpleEventListenerManagerImpl - No dispatcher for current simple listener manager, and default dispatcher is disabled.
02:55:49.341 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Listener manager is built: love.forte.simbot.core.event.SimpleEventListenerManagerImpl@68c72235
02:55:49.341 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Building providers...
02:55:49.341 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - There are no installed event providers. Try to find and install all event provider factories in current environment.
02:55:49.347 [main] INFO love.forte.simbot.application.ApplicationConfiguration - The size of providers built is 1
02:55:49.348 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - The built providers: [MiraiBotManager(bots=[], isActive=true, eventProcessorlove.forte.simbot.core.event.SimpleEventListenerManagerImpl@68c72235)@1687940142]
02:55:49.348 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Resolving bot verify infos and bot verify decoders...
02:55:49.353 [main] WARN love.forte.simbot.application.ApplicationConfiguration - Unable to find the com.charleskorn.kaml:kaml in current classpath, the bot configuration parser in *.bot.yaml format will not be available.
02:55:49.354 [main] WARN love.forte.simbot.application.ApplicationConfiguration - Unable to find the kotlinx-serialization-properties in current classpath, the bot configuration parser in *.bot.properties format will not be available.
02:55:49.356 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Using bot verify info decoder factories: [love.forte.simbot.bot.JsonBotVerifyInfoDecoder$Factory@193f604a]
02:55:49.359 [main] INFO love.forte.simboot.core.SimbootApp - Boot application completion via entrance class com.bot.qbot.SimbotExampleApplication with null
02:55:49.359 [main] DEBUG love.forte.simbot.application.ApplicationConfiguration - Registering bots...
02:55:49.366 [main] INFO love.forte.simbot.application.ApplicationConfiguration - The size of resolved bot verify infos is 1
02:55:49.366 [main] INFO love.forte.simbot.core.application.BaseApplicationBuilder.BotRegistrarImpl - Registering bot with verify info [love.forte.simbot.bot.ResourceAsBotVerifyInfo@10d307f1]
3月 19, 2023 2:55:49 上午 tools.Log_settler$Companion writelogError
严重: Bot Registration Failed!
Error Info:love.forte.simboot.core.SimbootApplicationException: Run boot app failure: required property 'component' cannot be found in current verify info simbot-bots/yourBot1.bot

(尤其最后的几行)



### 其他补充

另外反馈一个问题:在Windows环境下打包成的jar文件会出现问题:读取Bot文件时读取的是/BOOT-INF/layers.idx之类的奇奇怪怪的文件导致报错 换到Ubuntu环境下后该问题消失,出现以上问题  

全部文件详见github.com/enderman-teleporting/qbot中的v3-dev分支
ForteScarlet commented 1 year ago

首先尝试增加JVM参数

-Dfile.encoding=utf-8

或添加maven properties

<maven.compiler.encoding>UTF-8</maven.compiler.encoding>
Enderman-TPing commented 1 year ago

已添加maven properties 未能解决问题

严重: Bot Registration Failed!
Error Info:love.forte.simboot.core.SimbootApplicationException: Run boot app failure: required property 'component' cannot be found in current verify info simbot-bots/yourBot1.bot
Enderman-TPing commented 1 year ago
<properties>
        <java.version>17</java.version>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <simbot.version>3.0.0-RC.3</simbot.version>
        <simbot-mirai.version>3.0.0.0-RC</simbot-mirai.version>
        <kotlin.version>1.8.0</kotlin.version>
        <maven.compiler.encoding>UTF-8</maven.compiler.encoding>
    </properties>
ForteScarlet commented 1 year ago

测试了半天我才发现,你在尝试从 Spring Boot 环境中使用普通的 simbot-boot 启动方式。 尝试直接使用 Spring Boot 的启动方式:

@SpringBootApplication
@EnableSimbot
// other...
class App

fun main(args: Array<String>) {
    runApplication<App>(*args)
}

至于打包等其他相关问题,simbot-boot 模块也许可能存在某些问题,这也是为什么目前官方的快速开始中推荐使用 corespring-boot-starter块而并未提及使用 boot 模块的原因。

Enderman-TPing commented 1 year ago

感谢回复 问题解决了 抱歉带来麻烦