使用 Spring Boot 2
安装
准备一个 Spring Boot 2 项目,JDK 版本为 11 或更高,然后添加兼容 starter:
implementation("love.forte.simbot:simbot-core-spring-boot-starter-v2:5.0.0-Alpha2")
implementation 'love.forte.simbot:simbot-core-spring-boot-starter-v2:5.0.0-Alpha2'
<dependency>
<groupId>love.forte.simbot</groupId>
<artifactId>simbot-core-spring-boot-starter-v2</artifactId>
<version>5.0.0-Alpha2</version>
</dependency>
接入平台时还需要添加组件及其所需的网络引擎,参见 选择组件库。
与 Spring Boot 3 的主要差异
依赖坐标为
love.forte.simbot:simbot-core-spring-boot-starter-v2@EnableSimbot位于love.forte.simbot.spring2相关配置、处理器与应用实现主要位于
love.forte.simbot.spring2.*最低要求为 Java 11
使用
启用 simbot
在已有的 Spring Boot 启动类上添加 love.forte.simbot.spring2.EnableSimbot。
import love.forte.simbot.spring2.EnableSimbot
@EnableSimbot
@SpringBootApplication
class MyApplication
import love.forte.simbot.spring2.EnableSimbot;
@EnableSimbot
@SpringBootApplication
public class MyApplication {
// 保留已有的启动入口。
}
编写事件处理器
前往 编写事件处理器 了解更多。
注册拦截器
在 love.forte.simbot.spring2.configuration.application.SimbotApplicationPreConfigurer 中,可以通过 simbot Application 的 interceptorManager 在 Bot 自动加载前注册应用拦截器。参见 注册拦截器。
安装组件以及组件配置
前往 安装组件以及组件配置 了解更多。
注册Bot
前往 注册 Bot 了解更多。
运行或打包
前往 运行或打包 了解更多。
19 November 2026