简体   繁体   English

“java.lang.ExceptionInInitializerError”在带有正文的 RestAssured 发布请求中出错

[英]"java.lang.ExceptionInInitializerError" error in RestAssured post request with body

I'm using restassured library and at the below line i'm getting "java.lang.ExceptionInInitializerError" error caused by "Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make private java.lang.Class(java.lang.ClassLoader,java.lang.Class) accessible: module java.base does not "opens java.lang" to unnamed module @36f6e879" The baseURI is a http link and token_Body is alphanumeric string.我正在使用 restassured 库,在下面的行中,我收到由"java.lang.ExceptionInInitializerError" "Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make private java.lang.Class(java.lang.ClassLoader,java.lang.Class) accessible: module java.base does not "opens java.lang" to unnamed module @36f6e879" baseURI 是 http 链接,token_Body 是字母数字字符串。 I"m not sure what exactly is the issue. My java -version yields我不确定到底是什么问题。我的 java -version yields

"java version "18.0.1.1" 2022-04-22
Java(TM) SE Runtime Environment (build 18.0.1.1+2-6)
Java HotSpot(TM) 64-Bit Server VM (build 18.0.1.1+2-6, mixed mode, sharing)"

Code:代码:

String bearerToken = given(). with().
              header("Content-Type", "application/x-www-form-urlencoded"). body(token_Body).
              when(). post(baseURI). then(). extract().asString();

I have faced a similar issue, and I have solved it by updating the dependency of restassured to 4.5.1我遇到过类似的问题,我通过将 restassured 的依赖更新到 4.5.1 来解决它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM