Hibernate 前置插件,ORM 数据库框架,群/好友消息记录
-
Mirai Hibernate Plugin
Mirai Hibernate 前置插件
Mirai Console 的前置插件,用于 Hibernate ORM 框架的初始化
插件自带聊天记录器 MiraiHibernateRecorder,
会记录群聊/私聊
的内容到数据库方便其他插件使用,默认是h2database
数据库(since2.2.0+
)
数据库配置在config/xyz.cssxsh.mirai.plugin.mirai-hibernate-plugin/hibernate.properties
2.2.0
之前的版本的 默认数据库 为sqlite
, 你可以直接删掉hibernate.properties
, 让其重新生成h2database
配置数据库支持
本插件打包了以下版本的数据库驱动和连接池
mysql:mysql-connector-java:8.0.29
org.xerial:sqlite-jdbc:3.36.0.3
org.postgresql:postgresql:42.3.5
com.h2database:h2:2.1.212
com.zaxxer:HikariCP:5.0.1
需要其他数据库驱动支持请将 数据库驱动Jar包 放到
plugins
目录中一同被mirai-console
加载在插件项目中引用
repositories { mavenCentral() } dependencies { compileOnly("xyz.cssxsh.mirai:mirai-hibernate-plugin:${version}") }
一些方法和类说明
-
MiraiHibernateConfiguration
配置的,对应于JvmPlugin
的SessionFactory
默认将会读取(生成)在configFolder
目录下的hibernate.properties
作为配置文件
并且自动扫描加载JvmPlugin
所在类包下的被javax.persistence.Entity
标记的实体类 -
MiraiHibernateRecorder
是本插件自带的消息记录器,通过对MessageEvent
和MessagePostSendEvent
记录,保存消息历史到数据库 -
CriteriaBuilder.rand
MiraiHibernateConfiguration
中会对 Sqlite 的random
进行别名注册为rand
统一SQL语句的中的随机函数名
示例代码
安装
MCL 指令安装
./mcl --update-package xyz.cssxsh.mirai:mirai-hibernate-plugin --channel stable --type plugin
手动安装
- 运行 Mirai Console 生成
plugins
文件夹 - 从 Releases 下载
jar
并将其放入plugins
文件夹中
-
-
版本:2.2.3
配置文件:hibernate.connection.url=jdbc:mysql://localhost:3306/hibernate?autoReconnect=true hibernate.connection.driver_class=com.mysql.cj.jdbc.Driver hibernate.connection.CharSet=utf8mb4 hibernate.connection.useUnicode=true hibernate.connection.username=hibernate hibernate.connection.password=hibernate hibernate.dialect=org.hibernate.dialect.MySQL5Dialect hibernate.connection.provider_class=org.hibernate.hikaricp.internal.HikariCPConnectionProvider hibernate.hbm2ddl.auto=none hibernate-connection-autocommit=true hibernate.connection.show_sql=false hibernate.autoReconnect=true
错误日志:
2022-05-29 13:27:31 V/Bot.1234567890: [五字群名(123456798)] 昵称(123456789) -> [mirai:image:{8A9EA3CD-6F62-8D71-464A-B1311DCC7F98}.jpg] 2022-05-29 13:27:31 W/stderr: ERROR SqlExceptionHelper Table 'hibernate.message_record' doesn't exist 2022-05-29 13:27:31 W/stderr: ERROR SqlExceptionHelper Table 'hibernate.face_record' doesn't exist 2022-05-29 13:27:31 W/mirai-hibernate-plugin: SQLException in Recorder java.sql.SQLSyntaxErrorException: Table 'hibernate.message_record' doesn't exist at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:916) at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1061) at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdateInternal(ClientPreparedStatement.java:1009) at com.mysql.cj.jdbc.ClientPreparedStatement.executeLargeUpdate(ClientPreparedStatement.java:1320) at com.mysql.cj.jdbc.ClientPreparedStatement.executeUpdate(ClientPreparedStatement.java:994) at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeUpdate(ProxyPreparedStatement.java:61) at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeUpdate(HikariProxyPreparedStatement.java) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.executeUpdate(ResultSetReturnImpl.java:197) at org.hibernate.dialect.identity.GetGeneratedKeysDelegate.executeAndExtract(GetGeneratedKeysDelegate.java:58) at org.hibernate.id.insert.AbstractReturningDelegate.performInsert(AbstractReturningDelegate.java:43) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3279) at org.hibernate.persister.entity.AbstractEntityPersister.insert(AbstractEntityPersister.java:3885) at org.hibernate.action.internal.EntityIdentityInsertAction.execute(EntityIdentityInsertAction.java:84) at org.hibernate.engine.spi.ActionQueue.execute(ActionQueue.java:645) at org.hibernate.engine.spi.ActionQueue.addResolvedEntityInsertAction(ActionQueue.java:282) at org.hibernate.engine.spi.ActionQueue.addInsertAction(ActionQueue.java:263) at org.hibernate.engine.spi.ActionQueue.addAction(ActionQueue.java:317) at org.hibernate.event.internal.AbstractSaveEventListener.addInsertAction(AbstractSaveEventListener.java:330) at org.hibernate.event.internal.AbstractSaveEventListener.performSaveOrReplicate(AbstractSaveEventListener.java:287) at org.hibernate.event.internal.AbstractSaveEventListener.performSave(AbstractSaveEventListener.java:193) at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:123) at org.hibernate.event.internal.DefaultMergeEventListener.saveTransientEntity(DefaultMergeEventListener.java:271) at org.hibernate.event.internal.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:243) at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:175) at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:70) at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107) at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:829) at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:816) at mirai-hibernate-plugin-2.2.3.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder$merge$1.invoke(MiraiHibernateRecorder.kt:29) at mirai-hibernate-plugin-2.2.3.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder$merge$1.invoke(MiraiHibernateRecorder.kt:29) at mirai-hibernate-plugin-2.2.3.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateUtilsKt.useSession(MiraiHibernateUtils.kt:28) at mirai-hibernate-plugin-2.2.3.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder.merge(MiraiHibernateRecorder.kt:29) at mirai-hibernate-plugin-2.2.3.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder.access$merge(MiraiHibernateRecorder.kt:27) at mirai-hibernate-plugin-2.2.3.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder$record$1.invokeSuspend(MiraiHibernateRecorder.kt:35) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) 2022-05-29 13:27:31 W/mirai-hibernate-plugin: SQLException in Recorder java.sql.SQLSyntaxErrorException: Table 'hibernate.face_record' doesn't exist at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:120) at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) at com.mysql.cj.jdbc.ClientPreparedStatement.executeInternal(ClientPreparedStatement.java:916) at com.mysql.cj.jdbc.ClientPreparedStatement.executeQuery(ClientPreparedStatement.java:972) at com.zaxxer.hikari.pool.ProxyPreparedStatement.executeQuery(ProxyPreparedStatement.java:52) at com.zaxxer.hikari.pool.HikariProxyPreparedStatement.executeQuery(HikariProxyPreparedStatement.java) at org.hibernate.engine.jdbc.internal.ResultSetReturnImpl.extract(ResultSetReturnImpl.java:57) at org.hibernate.loader.Loader.getResultSet(Loader.java:2322) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2075) at org.hibernate.loader.Loader.executeQueryStatement(Loader.java:2037) at org.hibernate.loader.Loader.doQuery(Loader.java:956) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:357) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:327) at org.hibernate.loader.Loader.loadEntity(Loader.java:2440) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:77) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:61) at org.hibernate.persister.entity.AbstractEntityPersister.doLoad(AbstractEntityPersister.java:4521) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:4511) at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:571) at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:539) at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:208) at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:327) at org.hibernate.event.internal.DefaultLoadEventListener.doOnLoad(DefaultLoadEventListener.java:108) at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:74) at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:118) at org.hibernate.internal.SessionImpl.fireLoadNoChecks(SessionImpl.java:1231) at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1220) at org.hibernate.internal.SessionImpl.access$2100(SessionImpl.java:202) at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.doLoad(SessionImpl.java:2835) at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.lambda$load$1(SessionImpl.java:2812) at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.perform(SessionImpl.java:2768) at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2812) at org.hibernate.internal.SessionImpl.get(SessionImpl.java:1024) at org.hibernate.event.internal.DefaultMergeEventListener.entityIsDetached(DefaultMergeEventListener.java:306) at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:172) at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:70) at org.hibernate.event.service.internal.EventListenerGroupImpl.fireEventOnEachListener(EventListenerGroupImpl.java:107) at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:829) at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:816) at mirai-hibernate-plugin-2.2.3.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder$merge$1.invoke(MiraiHibernateRecorder.kt:29) at mirai-hibernate-plugin-2.2.3.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder$merge$1.invoke(MiraiHibernateRecorder.kt:29) at mirai-hibernate-plugin-2.2.3.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateUtilsKt.useSession(MiraiHibernateUtils.kt:28) at mirai-hibernate-plugin-2.2.3.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder.merge(MiraiHibernateRecorder.kt:29) at mirai-hibernate-plugin-2.2.3.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder.access$merge(MiraiHibernateRecorder.kt:27) at mirai-hibernate-plugin-2.2.3.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder$record$2.invokeSuspend(MiraiHibernateRecorder.kt:40) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
从报错来看是数据库中没有这两个表,手动试了下,是能够正常创建表的……
以前一直用的sqlite,升级到最新版之后每次启动都提示sqlite不支持多线程什么的,就想着干脆换成mysql -
@SnowMoonSS 在 Mirai Hibernate 前置插件,用于 Hibernate ORM 框架的初始化,历史消息持久化 中说:
hibernate.hbm2ddl.auto=none
改成
hibernate.hbm2ddl.auto=update
这样才会在没有表的时候创建表
推荐创建完表之后 改回none
-
@cssxsh 哦哦,感谢!
-
@cssxsh 直接下周release的话怎么配置自己的mysql url密码等信息哈
-
我的想法是下载源码,然后新建\src\main\resources\hibernate.properties文件,copy上面的配置信息,改url等为自己的?在打包新的jar,复制粘贴到plugins文件下?
-
@hellostronger 在 Mirai Hibernate 前置插件,用于 Hibernate ORM 框架的初始化,历史消息持久化 中说:
\src\main\resources\hibernate.properties
hibernate.properties 保存在
mcl\config\xyz.cssxsh.mirai.plugin.mirai-hibernate-plugin
你直接建好放进去,或者生成之后修改 -
你好,我下在的源码好像没这个路径哈
-
解决了,不是项目代码目录,是D:\Program Files\mirai-compose\config\xyz.cssxsh.mirai.plugin.mirai-hibernate-plugin,我用可视化界面,是那个软件下的某个目录,谢谢大佬的开源代码,牛
-
好奇就是图片那种,我要还原的话,在数据库里面持久化是{"type":"Image","imageId":"{CB648044-6933-13B4-7237-EDB07190E978}.jpg"}这样的,感觉还原不回去
-
-
后台最近疯狂报错,但是不影响使用,请问一下应该怎么解决
2022-07-04 22:39:18 W/mirai-hibernate-plugin: Exception in Recorder kotlin.UninitializedPropertyAccessException: lateinit property factory has not been initialized at mirai-hibernate-plugin-2.2.4.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateUtilsKt.getFactory(MiraiHibernateUtils.kt:19) at mirai-hibernate-plugin-2.2.4.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateUtilsKt.useSession(MiraiHibernateUtils.kt:32) at mirai-hibernate-plugin-2.2.4.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder.merge(MiraiHibernateRecorder.kt:29) at mirai-hibernate-plugin-2.2.4.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder.access$merge(MiraiHibernateRecorder.kt:27) at mirai-hibernate-plugin-2.2.4.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder$record$1.invokeSuspend(MiraiHibernateRecorder.kt:35) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664) 2022-07-04 22:39:18 W/mirai-hibernate-plugin: Exception in Recorder kotlin.UninitializedPropertyAccessException: lateinit property factory has not been initialized at mirai-hibernate-plugin-2.2.4.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateUtilsKt.getFactory(MiraiHibernateUtils.kt:19) at mirai-hibernate-plugin-2.2.4.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateUtilsKt.useSession(MiraiHibernateUtils.kt:32) at mirai-hibernate-plugin-2.2.4.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder.merge(MiraiHibernateRecorder.kt:29) at mirai-hibernate-plugin-2.2.4.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder.access$merge(MiraiHibernateRecorder.kt:27) at mirai-hibernate-plugin-2.2.4.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernateRecorder$record$2.invokeSuspend(MiraiHibernateRecorder.kt:40) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:570) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:749) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:677) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:664)
-
@39c5bb
正常来说,插件加载完成之后,机器人账号才会登录,才能接收到消息。
你这里怎么提前了 -
我也出现了39c5bb 的那个错误。bot接收一条消息就会报这个错一次,但是不影响使用。
-
-
启动的时候有这段
2022-07-06 16:21:45 I/org.hibernate.Version: HHH000412: Hibernate ORM core version [WORKING] 2022-07-06 16:21:45 I/org.hibernate.annotations.common.Version: HCANN000001: Hibernate Commons Annotations {5.1.2.Final} 2022-07-06 16:21:45 I/org.hibernate.dialect.Dialect: HHH000400: Using dialect: org.sqlite.hibernate.dialect.SQLiteDialect 2022-07-06 16:21:45 I/org.hibernate.engine.jdbc.connections.internal.ConnectionProviderInitiator: HHH000130: Instantiating explicit connection provider: org.hibernate.hikaricp.internal.HikariCPConnectionProvider 2022-07-06 16:21:45 I/com.zaxxer.hikari.HikariDataSource: HikariPool-1 - Starting... 2022-07-06 16:21:46 E/com.zaxxer.hikari.pool.HikariPool: HikariPool-1 - Exception during pool initialization. 2022-07-06 16:21:46 I/org.hibernate.service.internal.AbstractServiceRegistryImpl: HHH000369: Error stopping service [class org.hibernate.hikaricp.internal.HikariCPConnectionProvider] java.lang.NullPointerException: Cannot invoke "com.zaxxer.hikari.HikariDataSource.close()" because "this.hds" is null at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.hikaricp.internal.HikariCPConnectionProvider.stop(HikariCPConnectionProvider.java:122) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.service.internal.AbstractServiceRegistryImpl.stopService(AbstractServiceRegistryImpl.java:390) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.service.internal.AbstractServiceRegistryImpl.destroy(AbstractServiceRegistryImpl.java:373) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.destroy(StandardServiceRegistryImpl.java:129) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.service.spi.ServiceRegistryImplementor.close(ServiceRegistryImplementor.java:30) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:749) at mirai-hibernate-plugin-2.2.4.mirai.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernatePlugin.onEnable(MiraiHibernatePlugin.kt:45) at net.mamoe.mirai.console.internal.plugin.JvmPluginInternal.internalOnEnable$mirai_console(JvmPluginInternal.kt:119) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.enable(BuiltInJvmPluginLoaderImpl.kt:262) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.enable(BuiltInJvmPluginLoaderImpl.kt:34) at net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader$BuiltIn.enable(JvmPluginLoader.kt) at net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader$BuiltIn.enable(JvmPluginLoader.kt:50) at net.mamoe.mirai.console.plugin.PluginManager.enablePlugin(PluginManager.kt:173) at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.enableAllLoadedPlugins$mirai_console(PluginManagerImpl.kt:183) at net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge.doStart$mirai_console(MiraiConsoleImplementationBridge.kt:231) at net.mamoe.mirai.console.MiraiConsoleImplementation$Companion.start(MiraiConsoleImplementation.kt:444) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon(MiraiConsoleTerminalLoader.kt:159) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon$default(MiraiConsoleTerminalLoader.kt:158) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.main(MiraiConsoleTerminalLoader.kt:46) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.itxtech.mcl.Utility.bootJars(Utility.java:89) at org.itxtech.mcl.Utility.bootJars(Utility.java:79) at org.itxtech.mcl.Utility.bootMirai(Utility.java:101) at org.itxtech.mcl.module.builtin.Boot.boot(Boot.java:109) at org.itxtech.mcl.module.ModuleManager.phaseBoot(ModuleManager.java:148) at org.itxtech.mcl.Loader.lambda$start$4(Loader.java:189) at org.itxtech.mcl.Loader.tryCatching(Loader.java:146) at org.itxtech.mcl.Loader.start(Loader.java:189) at org.itxtech.mcl.Loader.main(Loader.java:79) 2022-07-06 16:21:46 E/mirai-hibernate-plugin: org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] org.hibernate.service.spi.ServiceException: Unable to create requested service [org.hibernate.engine.jdbc.env.spi.JdbcEnvironment] at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:275) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:237) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.id.factory.internal.DefaultIdentifierGeneratorFactory.injectServices(DefaultIdentifierGeneratorFactory.java:175) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.service.internal.AbstractServiceRegistryImpl.injectDependencies(AbstractServiceRegistryImpl.java:286) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:243) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.boot.internal.InFlightMetadataCollectorImpl.<init>(InFlightMetadataCollectorImpl.java:173) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.boot.model.process.spi.MetadataBuildingProcess.complete(MetadataBuildingProcess.java:127) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.boot.model.process.spi.MetadataBuildingProcess.build(MetadataBuildingProcess.java:86) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:479) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.boot.internal.MetadataBuilderImpl.build(MetadataBuilderImpl.java:85) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:709) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:746) at mirai-hibernate-plugin-2.2.4.mirai.jar//xyz.cssxsh.mirai.hibernate.MiraiHibernatePlugin.onEnable(MiraiHibernatePlugin.kt:45) at net.mamoe.mirai.console.internal.plugin.JvmPluginInternal.internalOnEnable$mirai_console(JvmPluginInternal.kt:119) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.enable(BuiltInJvmPluginLoaderImpl.kt:262) at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.enable(BuiltInJvmPluginLoaderImpl.kt:34) at net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader$BuiltIn.enable(JvmPluginLoader.kt) at net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader$BuiltIn.enable(JvmPluginLoader.kt:50) at net.mamoe.mirai.console.plugin.PluginManager.enablePlugin(PluginManager.kt:173) at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.enableAllLoadedPlugins$mirai_console(PluginManagerImpl.kt:183) at net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge.doStart$mirai_console(MiraiConsoleImplementationBridge.kt:231) at net.mamoe.mirai.console.MiraiConsoleImplementation$Companion.start(MiraiConsoleImplementation.kt:444) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon(MiraiConsoleTerminalLoader.kt:159) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon$default(MiraiConsoleTerminalLoader.kt:158) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.main(MiraiConsoleTerminalLoader.kt:46) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.itxtech.mcl.Utility.bootJars(Utility.java:89) at org.itxtech.mcl.Utility.bootJars(Utility.java:79) at org.itxtech.mcl.Utility.bootMirai(Utility.java:101) at org.itxtech.mcl.module.builtin.Boot.boot(Boot.java:109) at org.itxtech.mcl.module.ModuleManager.phaseBoot(ModuleManager.java:148) at org.itxtech.mcl.Loader.lambda$start$4(Loader.java:189) at org.itxtech.mcl.Loader.tryCatching(Loader.java:146) at org.itxtech.mcl.Loader.start(Loader.java:189) at org.itxtech.mcl.Loader.main(Loader.java:79) Caused by: org.hibernate.HibernateException: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Database may be already in use: null. Possible solutions: close all other connection(s); use the server mode [90020-212] at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.hikaricp.internal.HikariCPConnectionProvider.configure(HikariCPConnectionProvider.java:63) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.configureService(StandardServiceRegistryImpl.java:107) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.service.internal.AbstractServiceRegistryImpl.initializeService(AbstractServiceRegistryImpl.java:246) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.service.internal.AbstractServiceRegistryImpl.getService(AbstractServiceRegistryImpl.java:214) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.buildJdbcConnectionAccess(JdbcEnvironmentInitiator.java:146) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:66) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.engine.jdbc.env.internal.JdbcEnvironmentInitiator.initiateService(JdbcEnvironmentInitiator.java:35) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.boot.registry.internal.StandardServiceRegistryImpl.initiateService(StandardServiceRegistryImpl.java:101) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.service.internal.AbstractServiceRegistryImpl.createService(AbstractServiceRegistryImpl.java:263) ... 39 more Caused by: com.zaxxer.hikari.pool.HikariPool$PoolInitializationException: Failed to initialize pool: Database may be already in use: null. Possible solutions: close all other connection(s); use the server mode [90020-212] at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.pool.HikariPool.throwPoolInitializationException(HikariPool.java:596) at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:582) at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.pool.HikariPool.<init>(HikariPool.java:100) at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.HikariDataSource.<init>(HikariDataSource.java:81) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.hibernate.hikaricp.internal.HikariCPConnectionProvider.configure(HikariCPConnectionProvider.java:59) ... 47 more Caused by: org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database may be already in use: null. Possible solutions: close all other connection(s); use the server mode [90020-212] at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.message.DbException.getJdbcSQLException(DbException.java:678) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.message.DbException.getJdbcSQLException(DbException.java:477) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.message.DbException.get(DbException.java:212) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.mvstore.db.Store.convertMVStoreException(Store.java:165) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.mvstore.db.Store.<init>(Store.java:144) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.engine.Database.<init>(Database.java:324) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.engine.Engine.openSession(Engine.java:92) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.engine.Engine.openSession(Engine.java:222) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.engine.Engine.createSession(Engine.java:201) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.jdbc.JdbcConnection.<init>(JdbcConnection.java:122) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.Driver.connect(Driver.java:59) at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:121) at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ... 50 more Caused by: org.h2.mvstore.MVStoreException: The file is locked: /data/mirai/data/xyz.cssxsh.mirai.plugin.mirai-hibernate-plugin/hibernate.h2.mv.db [2.1.212/7] at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.mvstore.FileStore.open(FileStore.java:163) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.mvstore.MVStore.<init>(MVStore.java:449) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.mvstore.MVStore$Builder.open(MVStore.java:4118) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.mvstore.db.Store.<init>(Store.java:133) ... 62 more at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.util.DriverDataSource.getConnection(DriverDataSource.java:121) at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.pool.PoolBase.newConnection(PoolBase.java:359) at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.pool.PoolBase.newPoolEntry(PoolBase.java:201) at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.pool.HikariPool.createPoolEntry(HikariPool.java:470) at mirai-hibernate-plugin-2.2.4.mirai.jar//com.zaxxer.hikari.pool.HikariPool.checkFailFast(HikariPool.java:561) ... 50 more Caused by: org.h2.mvstore.MVStoreException: The file is locked: /data/mirai/data/xyz.cssxsh.mirai.plugin.mirai-hibernate-plugin/hibernate.h2.mv.db [2.1.212/7] at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.mvstore.DataUtils.newMVStoreException(DataUtils.java:1004) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.mvstore.FileStore.open(FileStore.java:163) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.mvstore.MVStore.<init>(MVStore.java:449) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.mvstore.MVStore$Builder.open(MVStore.java:4118) at mirai-hibernate-plugin-2.2.4.mirai.jar//org.h2.mvstore.db.Store.<init>(Store.java:133) ... 62 more
-
The file is locked: /data/mirai/data/xyz.cssxsh.mirai.plugin.mirai-hibernate-plugin/hibernate.h2.mv.db
@YoinSama
这个路径是可用的吗如果是可用的,检查插件是不是重复安装了,或者多个插件实例(mcl)占用这个文件
-
@cssxsh 我觉得应该是被占用了,我试着把服务器重启了之后,再启动就没这个问题了。辛苦大佬了
-
在插件项目中使用的话,hibernate.properties文件要放在哪呢?
-
@Abandoned9
如果你用的是 我插件里的 MiraiHibernateConfiguration
他会自动使用 在插件的 DataFolder 存放数据 -
@cssxsh 我就是创建了一个 Mirai-Console 的插件,然后gradle里面使用了
dependencies { compileOnly("xyz.cssxsh.mirai:mirai-hibernate-plugin:${version}") }
引入它,然后我该如何使用它?
如何配置数据库的信息?