@MrXiaoM 确定
suchenqaq 发布的最新帖子
-
RE: 如何 进行 get 或 post 方法请求啊
@MrXiaoM 就是打包哪里 mirai 插件下的 buildPlugin 和 gradle 自带的 build 和 jar 都试过
-
RE: 如何 进行 get 或 post 方法请求啊
@MrXiaoM 用了 在 build.gradle.kts 已经添加依赖了
dependencies{ // https://mvnrepository.com/artifact/org.apache.httpcomponents.client5/httpclient5 implementation("org.apache.httpcomponents.client5:httpclient5:5.2.1") }
用了 gradle 自带的编译和 mirai 都不行
-
RE: 如何 进行 get 或 post 方法请求啊
@MrXiaoM 使用 httpclinet5 库
String result = null;
// 初始化请求 post 对象
HttpPost post = new HttpPost("这是 url ");// 生成一个键值对数组
ArrayList<BasicNameValuePair> basicNameValuePairs = new ArrayList<>();// 添加键值对
basicNameValuePairs.add(new BasicNameValuePair("message", message));// 转换为 from 表单
post.setEntity(new UrlEncodedFormEntity(basicNameValuePairs));// 创建 http 对象
try(CloseableHttpClient aDefault = HttpClients.createDefault()) {// 执行请求
try (CloseableHttpResponse response = aDefault.execute(post)){// 获取结果对象
HttpEntity entity = response.getEntity();// 把结果对象转为字符串
result = EntityUtils.toString(entity);// 关闭
EntityUtils.consume(entity);} }catch (IOException | ParseException e) { System.out.println(e); }
-
RE: 如何 进行 get 或 post 方法请求啊
@MrXiaoM Failed to init MiraiConsole.
net.mamoe.mirai.console.internal.util.ServiceLoadException: Could not load service org.example.mirai.suchenqaq.chatgpt.JavaPluginMain.
at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadService(PluginServiceHelper.kt:62)
at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadAllServices(PluginServiceHelper.kt:44)
at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl$extractPlugins$findAllInstances$2.invoke(BuiltInJvmPluginLoaderImpl.kt:200)
at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl$extractPlugins$findAllInstances$2.invoke(BuiltInJvmPluginLoaderImpl.kt:195)
at kotlin.sequences.TransformingSequence$iterator$1.next(Sequences.kt:210)
at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:314)
at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:303)
at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:214)
at kotlin.sequences.TransformingSequence$iterator$1.hasNext(Sequences.kt:214)
at kotlin.sequences.FlatteningSequence$iterator$1.ensureItemIterator(Sequences.kt:307)
at kotlin.sequences.FlatteningSequence$iterator$1.hasNext(Sequences.kt:303)
at kotlin.sequences.SequencesKt___SequencesKt.toCollection(_Sequences.kt:787)
at kotlin.sequences.SequencesKt___SequencesKt.toSet(_Sequences.kt:828)
at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.extractPlugins(BuiltInJvmPluginLoaderImpl.kt:221)
at net.mamoe.mirai.console.internal.plugin.BuiltInJvmPluginLoaderImpl.listPlugins(BuiltInJvmPluginLoaderImpl.kt:71)
at net.mamoe.mirai.console.plugin.jvm.JvmPluginLoader$BuiltIn.listPlugins(JvmPluginLoader.kt)
at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.listAndSortAllPlugins(PluginManagerImpl.kt:195)
at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.findAndSortAllPluginsUsingBuiltInLoaders(PluginManagerImpl.kt:141)
at net.mamoe.mirai.console.internal.plugin.PluginManagerImpl.loadAllPluginsUsingBuiltInLoaders$mirai_console(PluginManagerImpl.kt:151)
at net.mamoe.mirai.console.internal.MiraiConsoleImplementationBridge.doStart$mirai_console(MiraiConsoleImplementationBridge.kt:302)
at net.mamoe.mirai.console.MiraiConsoleImplementation$Companion.start(MiraiConsoleImplementation.kt:512)
at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon(MiraiConsoleTerminalLoader.kt:182)
at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.startAsDaemon$default(MiraiConsoleTerminalLoader.kt:181)
at net.mamoe.mirai.console.terminal.MiraiConsoleTerminalLoader.main(MiraiConsoleTerminalLoader.kt:59)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at org.itxtech.mcl.Utility.bootJars(Utility.java:86)
at org.itxtech.mcl.Utility.bootJars(Utility.java:76)
at org.itxtech.mcl.Utility.bootMirai(Utility.java:98)
at org.itxtech.mcl.module.builtin.Boot.boot(Boot.java:113)
at org.itxtech.mcl.module.ModuleManager.phaseBoot(ModuleManager.java:123)
at org.itxtech.mcl.Loader.lambda$start$4(Loader.java:196)
at org.itxtech.mcl.Loader.tryCatching(Loader.java:151)
at org.itxtech.mcl.Loader.start(Loader.java:196)
at org.itxtech.mcl.Loader.main(Loader.java:84)
Caused by: java.lang.NoClassDefFoundError: org/apache/hc/core5/http/ParseException
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at net.mamoe.mirai.console.internal.util.PluginServiceHelper.loadService(PluginServiceHelper.kt:53)
... 36 more
Caused by: java.lang.ClassNotFoundException: org.apache.hc.core5.http.ParseException
at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:587)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
at net.mamoe.mirai.console.internal.plugin.JvmPluginClassLoaderN.loadClass(JvmPluginClassLoader.kt:500)
... 39 more