好可爱
sweetymajo 发布的帖子
-
RE: 想收集一下现在大家对于mirai的使用情况
还在使用mirai吗:是
通过那种登录方式使用的mirai:
1.签名服务
mirai登录情况稳定吗:稳定
mirai的相关功能使用方式:
1.mirai插件
使用mirai的相关平台:linux -
RE: 请教一下如何使用/src/main/resources下的文件?
@cssxsh 反复折腾了一下午,终于搞定了。感谢大佬提供的思路。
现在提供一下我的做法:
fun startWebServer(){ val env = applicationEngineEnvironment { envConfig() } val webServer = embeddedServer(Netty, env) GlobalScope.launch { webServer.start(true) } } private fun ApplicationEngineEnvironmentBuilder.envConfig() { classLoader = XXXBot::class.java.classLoader module { module() } connector { host = "0.0.0.0" port = 8080 } }
-
RE: 请教一下如何使用/src/main/resources下的文件?
@cssxsh 非常感谢解答,我目前刚接触java相关的开发,对于classLoader没什么概念,我先去调查一下相关的资料。
-
RE: 请教一下如何使用/src/main/resources下的文件?
@diyigemt 非常感谢解答。我现在就是采用的这种方式解决的。
但是感觉不是很方便。这样每次部署插件的时候,需要将静态页面和动态页面的文件从resources下先释放到本地路径下再使用。总感觉自己绕了很大的弯路,所以想看看是否有直接使用resources下文件的方法。 -
RE: 请教一下如何使用/src/main/resources下的文件?
@Samarium150 这块的资料调查过了,那个是直接获取资源文件的内容,而这里是指定资源文件的路径,似乎不太适合用这个方法。
-
请教一下如何使用/src/main/resources下的文件?
可能问的问题比较愚蠢。
我是一个新手,之前有过别的语言的开发经验,但是没接触过java和kotlin。最近在尝试kotlin开发mirai插件。
我想使用Ktor做一个静态网页服务。
以下的代码在一般程序下kotlin程序下有效,但是在mirai插件中无法生效。
(文件路径为/src/main/resources/static/index.html)route("/") { static { resource("", "index.html", "static") } }
我kotlin开发经验不足,大概猜测在mirai插件中无法直接使用/src/main/resources下的文件,因此请教一下应该如何读取这样的文件。
-
RE: IDEA中执行Run Mirai Console报错
@JiuMu-i 在build.gradle.kts这个文件中,修改id("net.mamoe.mirai-console")这行后面的version为"2.13.0-RC2"
-
IDEA中执行Run Mirai Console报错
尝试新建了空的工程,也会报错。
附上debug-sandbox目录下的日志内容:
2022-11-05 21:12:43 I/main: Starting mirai-console... 2022-11-05 21:12:44 I/main: ==================================[ Mirai consosle 2.13.0 ]=================================== __ __ __ __ ______ __ | \ / \ \ | \/ \ | \ | ▓▓\ / ▓▓\▓▓ ______ ______ \▓▓ ▓▓▓▓▓▓\ ______ _______ _______ ______ | ▓▓ ______ | ▓▓▓\ / ▓▓▓ \/ \ | \| \ ▓▓ \▓▓/ \| \ / \/ \| ▓▓/ \ | ▓▓▓▓\ ▓▓▓▓ ▓▓ ▓▓▓▓▓▓\ \▓▓▓▓▓▓\ ▓▓ ▓▓ | ▓▓▓▓▓▓\ ▓▓▓▓▓▓▓\ ▓▓▓▓▓▓▓ ▓▓▓▓▓▓\ ▓▓ ▓▓▓▓▓▓\ | ▓▓\▓▓ ▓▓ ▓▓ ▓▓ ▓▓ \▓▓/ ▓▓ ▓▓ ▓▓ __| ▓▓ | ▓▓ ▓▓ | ▓▓\▓▓ \| ▓▓ | ▓▓ ▓▓ ▓▓ ▓▓ | ▓▓ \▓▓▓| ▓▓ ▓▓ ▓▓ | ▓▓▓▓▓▓▓ ▓▓ ▓▓__/ \ ▓▓__/ ▓▓ ▓▓ | ▓▓_\▓▓▓▓▓▓\ ▓▓__/ ▓▓ ▓▓ ▓▓▓▓▓▓▓▓ | ▓▓ \▓ | ▓▓ ▓▓ ▓▓ \▓▓ ▓▓ ▓▓\▓▓ ▓▓\▓▓ ▓▓ ▓▓ | ▓▓ ▓▓\▓▓ ▓▓ ▓▓\▓▓ \ \▓▓ \▓▓\▓▓\▓▓ \▓▓▓▓▓▓▓\▓▓ \▓▓▓▓▓▓ \▓▓▓▓▓▓ \▓▓ \▓▓\▓▓▓▓▓▓▓ \▓▓▓▓▓▓ \▓▓ \▓▓▓▓▓▓▓ 2022-11-05 21:12:44 I/main: Backend: version 2.13.0, built on 2022-11-01 10:47:11. 2022-11-05 21:12:44 I/main: Frontend Terminal: version 2.13.0, provided by Mamoe Technologies 2022-11-05 21:12:44 I/main: Welcome to visit https://mirai.mamoe.net/ 2022-11-05 21:12:44 W/MultiFilePluginDataStorageImpl: Could not save AutoLogin in YAML format due to exception in YAML encoder. Please report this exception and relevant configurations to https://github.com/mamoe/mirai/issues/new/choose java.util.ServiceConfigurationError: net.mamoe.mirai.IMirai: Provider net.mamoe.mirai.internal.MiraiImpl could not be instantiated at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:586) at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:813) at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729) at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403) at kotlin.collections.CollectionsKt___CollectionsKt.firstOrNull(_Collections.kt:272) at net.mamoe.mirai.utils.ServicesKt.loadService(Services.kt:18) at net.mamoe.mirai.Mirai.findMiraiInstance(IMirai.kt:357) at net.mamoe.mirai._MiraiInstance.get(IMirai.kt:348) at net.mamoe.mirai.Mirai.getInstance(IMirai.kt:39) at net.mamoe.mirai.internal.message.MessageSerializersImpl.getSerializersModule(MessageSerializersImpl.kt:65) at net.mamoe.mirai.message.MessageSerializers$INSTANCE.getSerializersModule(MessageSerializers.kt) at net.mamoe.mirai.console.internal.data.MultiFilePluginDataStorageImpl$createYaml$1.invoke(MultiFilePluginDataStorageImpl.kt:114) at net.mamoe.mirai.console.internal.data.MultiFilePluginDataStorageImpl$createYaml$1.invoke(MultiFilePluginDataStorageImpl.kt:112) at net.mamoe.yamlkt.YamlKt.Yaml(Yaml.kt:242) at net.mamoe.yamlkt.YamlKt.Yaml$default(Yaml.kt:240) at net.mamoe.mirai.console.internal.data.MultiFilePluginDataStorageImpl.createYaml(MultiFilePluginDataStorageImpl.kt:112) at net.mamoe.mirai.console.internal.data.MultiFilePluginDataStorageImpl.store(MultiFilePluginDataStorageImpl.kt:85) at net.mamoe.mirai.console.internal.data.MultiFilePluginDataStorageImpl.load(MultiFilePluginDataStorageImpl.kt:52) at net.mamoe.mirai.console.internal.data.builtins.ConsoleDataScopeImpl.addAndReloadConfig(ConsoleDataScopeImpl.kt:41) at net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge.doStart$mirai_console(MiraiConsoleImplementationBridge.kt:265) at net.mamoe.mirai.console.MiraiConsoleImplementation$Companion.start(MiraiConsoleImplementation.kt:508) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon(MiraiConsoleTerminalLoader.kt:177) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon$default(MiraiConsoleTerminalLoader.kt:176) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.main(MiraiConsoleTerminalLoader.kt:54) Caused by: java.util.ServiceConfigurationError: net.mamoe.mirai.IMirai: Provider net.mamoe.mirai.internal.MiraiImpl could not be instantiated at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:586) at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:813) at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729) at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403) at kotlin.collections.CollectionsKt___CollectionsKt.firstOrNull(_Collections.kt:272) at net.mamoe.mirai.utils.ServicesKt.loadService(Services.kt:18) at net.mamoe.mirai.Mirai.findMiraiInstance(IMirai.kt:357) at net.mamoe.mirai._MiraiInstance.get(IMirai.kt:348) at net.mamoe.mirai.Mirai.getInstance(IMirai.kt:39) at net.mamoe.mirai.internal.message.MessageSerializersImpl.getSerializersModule(MessageSerializersImpl.kt:65) at net.mamoe.mirai.internal.message.MessageSerializersImpl.registerSerializers(MessageSerializersImpl.kt:76) at net.mamoe.mirai.message.MessageSerializers$INSTANCE.registerSerializers(MessageSerializers.kt) at net.mamoe.mirai.internal.message.protocol.MessageProtocolFacade.<clinit>(MessageProtocolFacade.kt:165) at net.mamoe.mirai.internal.MiraiImplKt._MiraiImpl_static_init(MiraiImpl.kt:25) at net.mamoe.mirai.internal.MiraiImpl.<clinit>(MiraiImpl.kt:87) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789) ... 22 more Caused by: java.lang.NoClassDefFoundError: net/mamoe/mirai/internal/deps/io/ktor/client/engine/okhttp/OkHttp at net.mamoe.mirai.internal.MiraiImplKt.createDefaultHttpClient(MiraiImpl.kt:29) at net.mamoe.mirai.internal.MiraiImpl.<init>(MiraiImpl.kt:97) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789) ... 41 more Caused by: java.lang.ClassNotFoundException: net.mamoe.mirai.internal.deps.io.ktor.client.engine.okhttp.OkHttp at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520) ... 49 more 2022-11-05 21:12:44 E/main: Failed to init MiraiConsole. java.lang.IllegalStateException: Exception while saving net.mamoe.mirai.console.internal.data.builtins.AutoLoginConfig@5e9456ae, saveName=AutoLogin at net.mamoe.mirai.console.internal.data.MultiFilePluginDataStorageImpl.store(MultiFilePluginDataStorageImpl.kt:105) at net.mamoe.mirai.console.internal.data.MultiFilePluginDataStorageImpl.load(MultiFilePluginDataStorageImpl.kt:52) at net.mamoe.mirai.console.internal.data.builtins.ConsoleDataScopeImpl.addAndReloadConfig(ConsoleDataScopeImpl.kt:41) at net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge.doStart$mirai_console(MiraiConsoleImplementationBridge.kt:265) at net.mamoe.mirai.console.MiraiConsoleImplementation$Companion.start(MiraiConsoleImplementation.kt:508) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon(MiraiConsoleTerminalLoader.kt:177) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon$default(MiraiConsoleTerminalLoader.kt:176) at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.main(MiraiConsoleTerminalLoader.kt:54) Caused by: java.util.ServiceConfigurationError: net.mamoe.mirai.IMirai: Provider net.mamoe.mirai.internal.MiraiImpl could not be instantiated at java.base/java.util.ServiceLoader.fail(ServiceLoader.java:586) at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:813) at java.base/java.util.ServiceLoader$ProviderImpl.get(ServiceLoader.java:729) at java.base/java.util.ServiceLoader$3.next(ServiceLoader.java:1403) at kotlin.collections.CollectionsKt___CollectionsKt.firstOrNull(_Collections.kt:272) at net.mamoe.mirai.utils.ServicesKt.loadService(Services.kt:18) at net.mamoe.mirai.Mirai.findMiraiInstance(IMirai.kt:357) at net.mamoe.mirai._MiraiInstance.get(IMirai.kt:348) at net.mamoe.mirai.Mirai.getInstance(IMirai.kt:39) at net.mamoe.mirai.internal.message.MessageSerializersImpl.getSerializersModule(MessageSerializersImpl.kt:65) at net.mamoe.mirai.message.MessageSerializers$INSTANCE.getSerializersModule(MessageSerializers.kt) at net.mamoe.mirai.console.internal.data.MultiFilePluginDataStorageImpl$store$2$1.invoke(MultiFilePluginDataStorageImpl.kt:96) at net.mamoe.mirai.console.internal.data.MultiFilePluginDataStorageImpl$store$2$1.invoke(MultiFilePluginDataStorageImpl.kt:95) at kotlinx.serialization.json.JsonKt.Json(Json.kt:138) at kotlinx.serialization.json.JsonKt.Json$default(Json.kt:136) at net.mamoe.mirai.console.internal.data.MultiFilePluginDataStorageImpl.store(MultiFilePluginDataStorageImpl.kt:95) ... 7 more Caused by: java.lang.NoClassDefFoundError: Could not initialize class net.mamoe.mirai.internal.MiraiImpl at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:77) at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Constructor.java:499) at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480) at java.base/java.util.ServiceLoader$ProviderImpl.newInstance(ServiceLoader.java:789) ... 21 more