Mirai组件 Springboot快速启动器


项目地址

Github or Gitee

使用

首先,引入依赖;

https://search.maven.org/artifact/love.forte.simple-robot/component-mirai-spring-boot-starter

Maven

<dependency>
    <groupId>love.forte.simple-robot</groupId>
    <artifactId>component-mirai-spring-boot-starter</artifactId>
    <version>${version}</version>
</dependency>

Gradle

implementation 'love.forte.simple-robot:component-mirai-spring-boot-starter:${version}'

然后编写好配置类(与Springboot公用一个application.properties配置类)后启动即可。 例如:

# simbot的包扫描路径
simbot.core.scannerPackage=com.bot.listener
# ${账号1}:${密码1},${账号2}:${密码2}...
simbot.core.bots=111111:abcdefg
@SpringBootApplication
public class RunApplication {
    public static void main(String[] args) {
        SpringApplication.run(RunApplication.class, args);
    }
}

kotlin

从mirai的v1.2.0开始,便使用了1.4.0版本的kotlin1.3.9版本的kotlinx-coroutines。 如果你出现了类似于NoClassDefFoundError的错误且找不到的类是kotlin下的东西,例如kotlin/coroutines/EmptyCoroutineContext, 则请尝试手动导入1.4.10版本的kotlin

以maven为例:

       <dependency>
           <groupId>org.jetbrains.kotlin</groupId>
           <artifactId>kotlin-stdlib-jdk8</artifactId>
           <version>${kotlin.version}</version>
       </dependency>
       <!-- kt -->
       <dependency>
           <groupId>org.jetbrains.kotlin</groupId>
           <artifactId>kotlin-stdlib</artifactId>
           <version>${kotlin.version}</version>
       </dependency>
        <!-- ktx coroutines core -->
        <dependency>
            <groupId>org.jetbrains.kotlinx</groupId>
            <artifactId>kotlinx-coroutines-core</artifactId>
            <version>${kotlinx-coroutines-core.version}</version>
        </dependency>

其中,${kotlin.version}1.4.10, ${kotlinx-coroutines-core.version}1.3.9.

核心启动器

每一个组件启动器中一般来说都包含一个核心启动器。

正常情况下,你无需手动导入此坐标。

核心启动器的坐标为:

仓库地址:https://search.maven.org/artifact/io.github.ForteScarlet.simple-robot/core-spring-boot-starter

<dependency>
    <groupId>io.github.ForteScarlet.simple-robot</groupId>
    <artifactId>core-spring-boot-starter</artifactId>
    <version>${version}</version>
</dependency>

但是,假如:组件启动器的版本为1.9.1,而前缀同为1.9的核心启动器的最新一个版本是1.9.2,那么你可以选择手动导入这个更新一个版本的核心来升级内部的核心启动器。

其他链接

核心

https://github.com/ForteScarlet/simple-robot-core

Mirai组件

https://github.com/ForteScarlet/simple-robot-component-mirai

核心Springboot启动器

https://github.com/ForteScarlet/simple-robot-core-springboot-starter

更新日志

查看 UPDATE.md 文件