You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何修复Brobot中ActionLogger Bean缺失的报错问题?

集成Brobot的Spring Boot应用更新后Bean找不到问题修复

问题描述

我正在开发一个集成Brobot的Spring Boot应用,更新该库后启动报错,提示无法找到ActionLogger类型的Bean,不清楚该如何修复。

报错信息

2024-09-17T12:26:53.922+02:00  WARN 2816 --- [tw-check] [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'twCheckTestApplication': Unsatisfied dependency expressed through field 'actionLogger': No qualifying bean of type 'io.github.jspinak.brobot.logging.ActionLogger' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}


***************************
APPLICATION FAILED TO START
***************************

Description:

Field actionLogger in com.example.tw.TwCheckTestApplication required a bean of type 'io.github.jspinak.brobot.logging.ActionLogger' that could not be found.

The injection point has the following annotations:
    - @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'io.github.jspinak.brobot.logging.ActionLogger' in your configuration.

主类代码

package com.example.tw;

import com.example.tw.controller.DatabaseController.DatabaseController;
import com.example.tw.utils.RobotCommands;
import io.github.jspinak.brobot.logging.ActionLogger;
import org.sikuli.script.ImagePath;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.annotation.ComponentScan;

import java.sql.Connection;

/**
 * The TwCheckTestApplication class is the main class of the project. This is where the database and brobot are configured.
 */
@SpringBootApplication
@ComponentScan(basePackages = {"io.github.jspinak.brobot", "com.example.tw"})
public class TwCheckTestApplication {

    public static void main(String[] args) {
        Connection dataTable = DatabaseController.connect();
        if (dataTable != null) {
            ImagePath.setBundlePath("images");

            // Add image path for other folders
            ImagePath.add("images/guestMode");
            ImagePath.add("images/chooseEngine");
            ImagePath.add("images/allMovement");
            ImagePath.add("images/connectionAndLinkMovement");
            ImagePath.add("images/Initiate");
            ImagePath.add("images/EditJSON");
            ImagePath.add("images/ImportImg");
            ImagePath.add("images/Branding");
            ImagePath.add("images/addVirtualStaging");
            ImagePath.add("images/addOverlays");
            ImagePath.add("images/itemVisibility");
            ImagePath.add("images/addAudio");
            ImagePath.add("images/allAnimations");
            ImagePath.add("images/checkTeleport");
            ImagePath.add("images/checkTags");
            ImagePath.add("images/addImagesAndTexts");
            ImagePath.add("images/checkMoveToLink");


            SpringApplicationBuilder builder = new SpringApplicationBuilder(TwCheckTestApplication.class);
            builder.headless(false);
            builder.run(args);

            RobotCommands.openChrome();
            RobotCommands.enterURL("http://localhost:8080/test-interface");
        } else {
            System.exit(0);
        }
    }
}

修复方案

1. 确认Brobot自动配置是否生效

检查更新后的Brobot版本是否需要特定启用注解(比如@EnableBrobot),如果有,将其添加到主类上,替换或补充现有@ComponentScan:

@SpringBootApplication
@EnableBrobot // 新增该注解(若Brobot新版本提供)
public class TwCheckTestApplication {
    // ... 原有代码
}

2. 手动声明ActionLogger Bean

如果Brobot库未自动配置该Bean,创建一个配置类手动定义:

@Configuration
public class BrobotLoggingConfig {
    @Bean
    public ActionLogger actionLogger() {
        // 根据Brobot文档传入必要构造参数(若有)
        return new ActionLogger();
    }
}

3. 验证扫描范围与依赖完整性

  • 检查依赖jar包中是否存在io.github.jspinak.brobot.logging.ActionLogger类,确认包路径无误。
  • 确认@ComponentScan的basePackages覆盖了Brobot所有需要扫描的包,新版本可能新增子包,需确保范围完整。

4. 排查版本兼容性

确认更新后的Brobot版本与当前Spring Boot版本兼容,通过mvn dependency:tree(Maven)或./gradlew dependencies(Gradle)检查依赖冲突,必要时调整版本号。


内容的提问来源于stack exchange,提问作者teo emirot

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.18 09:06:00