我正在创建一个使用(非官方)Discord API、JDA 的(Minecraft)Forge mod。我在 Eclipse IDE 中执行此操作。
在 IDE 中,我可以很好地添加带有依赖项的 JDA,并且代码中不会出现任何错误。然后,使用 gradlew 并编译它,当我尝试运行它(在 Minecraft 中)时出现错误。
我让几个人检查我的 build.gradle 以确保它是正确的,而且确实如此。我现在假设这是一个一般的 Java 错误。
无论如何,错误:
java.lang.NoClassDefFoundError: org/apache/http/nio/reactor/IOReactorException
at com.mashape.unirest.http.HttpClientHelper.prepareRequest(HttpClientHelper.java:151)
at com.mashape.unirest.http.HttpClientHelper.request(HttpClientHelper.java:131)
at com.mashape.unirest.request.BaseRequest.asString(BaseRequest.java:56)
at net.dv8tion.jda.requests.Requester.toObject(Requester.java:100)
at net.dv8tion.jda.requests.Requester.post(Requester.java:55)
at net.dv8tion.jda.entities.impl.JDAImpl.login(JDAImpl.java:152)
at net.dv8tion.jda.JDABuilder.buildAsync(JDABuilder.java:272)
at net.dv8tion.jda.JDABuilder.buildBlocking(JDABuilder.java:307)
at com.scarabcoder.ereijan.gui.GuiLogin.connect(GuiLogin.java:168)
at com.scarabcoder.ereijan.gui.GuiLogin.func_146284_a(GuiLogin.java:143)
at net.minecraft.client.gui.GuiScreen.func_73864_a(GuiScreen.java:466)
at com.scarabcoder.ereijan.gui.GuiLogin.func_73864_a(GuiLogin.java:128)
at net.minecraft.client.gui.GuiScreen.func_146274_d(GuiScreen.java:554)
at net.minecraft.client.gui.GuiScreen.func_146269_k(GuiScreen.java:523)
at net.minecraft.client.Minecraft.func_71407_l(Minecraft.java:1674)
at net.minecraft.client.Minecraft.func_71411_J(Minecraft.java:1024)
at net.minecraft.client.Minecraft.func_99999_d(Minecraft.java:349)
at net.minecraft.client.main.Main.main(SourceFile:124)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at net.minecraft.launchwrapper.Launch.launch(Launch.java:135)
at net.minecraft.launchwrapper.Launch.main(Launch.java:28)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at …Run Code Online (Sandbox Code Playgroud) 我正在尝试在 create-react-app 应用程序中导入 got ( https://www.npmjs.com/package/got ),当我只是尝试将其导入到一个文件中时,甚至不尝试执行任何代码应用程序无法编译,我收到以下错误:
util.js:601 Uncaught TypeError: The "original" argument must be of type Function
at Object.promisify (util.js:601)
at Object.<anonymous> (get-body-size.js:7)
at Object../node_modules/got/dist/source/utils/get-body-size.js (get-body-size.js:30)
at __webpack_require__ (bootstrap:784)
at fn (bootstrap:150)
at Object.<anonymous> (normalize-arguments.js:15)
at Object../node_modules/got/dist/source/normalize-arguments.js (normalize-arguments.js:441)
at __webpack_require__ (bootstrap:784)
at fn (bootstrap:150)
at Object.<anonymous> (as-promise.js:8)
at Object../node_modules/got/dist/source/as-promise.js (as-promise.js:152)
at __webpack_require__ (bootstrap:784)
at fn (bootstrap:150)
at Object../node_modules/got/dist/source/create.js (create.js:4)
at __webpack_require__ (bootstrap:784)
at fn (bootstrap:150)
at Object../node_modules/got/dist/source/index.js (index.js:7)
at __webpack_require__ (bootstrap:784)
at fn (bootstrap:150)
at Object../src/utils/ph_loader.js (ph_loader.js:1)
at __webpack_require__ …Run Code Online (Sandbox Code Playgroud) 我创建了一个像这样的守卫
import { Injectable, CanActivate, ExecutionContext } from '@nestjs/common';
import { AuthService } from './auth.service';
@Injectable()
export class CompanyGuard implements CanActivate {
constructor(private readonly authService: AuthService) {}
async canActivate(context: ExecutionContext): Promise<boolean> {
const request = context.switchToHttp().getRequest();
const token = request.headers['token'];
if (token) {
const company = await this.authService.validateToken(token);
return company ? true : false;
} else {
return false;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我想将 Company 的值保留在请求对象上,以便稍后可以在控制器上使用它。如何在 Nest.js 中做到这一点?我试图在文档中查看它,但我很困惑。我应该使用会话还是有更简单的方法来做到这一点?
我不明白,如果选项为 None,为什么要评估 Option.and() 。文档说....
如果选项为 None,则返回 None,否则返回 optb(and() 的参数)。
所以我希望,如果选项不是“无”,则仅(且仅在那时)考虑 and() 。但显然事实并非如此。让我们看看下面的代码......
let n: Option<i32> = None;
let m = n.and(Some(n.unwrap()));
Run Code Online (Sandbox Code Playgroud)
我知道这是一个愚蠢的示例,但这只是为了让我的观点更清楚。
exports.sendInvite = functions.firestore
.document("invites/{phoneNumber}")
.onCreate(async (doc) => { //error is here I assume
const from = "+<mynumber>";
const to = doc.data().phoneNumber;
const text = "You can join the club now";
return client.messages.create(from, to, text);
});
Run Code Online (Sandbox Code Playgroud)
我的 .eslintrc.js
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"google",
],
rules: {
quotes: ["error", "double"],
},
};
Run Code Online (Sandbox Code Playgroud)
我的 firebase 云函数抛出了这个错误Parsing error: Unexpected token =>。有谁知道为什么会这样?顺便说一句,我使用的是 javascript 而不是 TS。

我看过其他帖子也有相同的错误消息,但找不到任何适合我的解决方案。我使用的是 Windows 10。我已完成所有必需的步骤,但仍然弹出错误。
我遇到了一个我无法理解的python字符串模块的问题。为什么是 '' in string.whitespace空字符串(因此不可见)?如果是的话;为什么它不在list(string.whitespace)?
如何让is_power_of函数返回数字是否是给定基数的幂?假设基数为正数。
def is_power_of(number, base):
# Base case: when number is smaller than base.
if number < base:
# If number is equal to 1, it's a power (base**0).
return __
# Recursive case: keep dividing number by base.
return is_power_of(__, ___)
print(is_power_of(8,2)) # Should be True
print(is_power_of(64,4)) # Should be True
print(is_power_of(70,10)) # Should be False
Run Code Online (Sandbox Code Playgroud) javascript ×3
python ×2
arduino ×1
arduino-ide ×1
eslint ×1
java ×1
nestjs ×1
node.js ×1
node.js-got ×1
npm ×1
option-type ×1
panic ×1
python-3.x ×1
rust ×1
string ×1
unwrap ×1
windows-10 ×1