如何使用 Maven 安装 unirest?

Posted

技术标签:

【中文标题】如何使用 Maven 安装 unirest?【英文标题】:How to install a unirest with Maven? 【发布时间】:2021-09-15 13:04:58 【问题描述】:

我正在尝试安装 unirest-java。我对cmd不是很熟悉。所以我一步一步地按照他们的指示,然后在我运行最后一步之后它失败了,我不知道它为什么会发生。

这是我遵循的说明的链接: https://konghq.com/blog/installing-unirest-java-with-the-maven-assembly-plugin/

除了clean assembly:assembly之外,我还尝试了-Denforcer.skip

结果如下:(我跳过了前几行,因为我不能发布超过 30000 个字符的内容)

[ERROR] Tests run: 6, Failures: 5, Errors: 0, Skipped: 1, Time elapsed: 0.018 s <<< FAILURE! - in BehaviorTests.BodyLogSummaryTest
[ERROR] forSimpleBodies  Time elapsed: 0.003 s  <<< FAILURE!
org.opentest4j.AssertionFailedError:
expected: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
this is the body> but was: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
this is the body>
        at BehaviorTests.BodyLogSummaryTest.forSimpleBodies(BodyLogSummaryTest.java:62)

[ERROR] forObjectBodies  Time elapsed: 0.001 s  <<< FAILURE!
org.opentest4j.AssertionFailedError:
expected: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
"bar":"zip"> but was: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
"bar":"zip">
        at BehaviorTests.BodyLogSummaryTest.forObjectBodies(BodyLogSummaryTest.java:94)

[ERROR] forSimpleGets  Time elapsed: 0.001 s  <<< FAILURE!
org.opentest4j.AssertionFailedError:
expected: <GET http://somewhere/beans?fruit=apple
Accept=image/raw
===================================> but was: <GET http://somewhere/beans?fruit=apple
Accept=image/raw
===================================>
        at BehaviorTests.BodyLogSummaryTest.forSimpleGets(BodyLogSummaryTest.java:47)

[ERROR] forJsonBodies  Time elapsed: 0.001 s  <<< FAILURE!
org.opentest4j.AssertionFailedError:
expected: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
"muppet":"Gonzo"> but was: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
"muppet":"Gonzo">
        at BehaviorTests.BodyLogSummaryTest.forJsonBodies(BodyLogSummaryTest.java:78)

[ERROR] simpleFormBody  Time elapsed: 0.005 s  <<< FAILURE!
org.opentest4j.AssertionFailedError:
expected: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
album=77&band=Talking+Heads> but was: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
album=77&band=Talking+Heads>
        at BehaviorTests.BodyLogSummaryTest.simpleFormBody(BodyLogSummaryTest.java:111)

[INFO] Running BehaviorTests.CachingAlternativeTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in BehaviorTests.CachingAlternativeTest
[INFO] Running BehaviorTests.CachingTest
[INFO] Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.017 s - in BehaviorTests.CachingTest
[INFO] Running BehaviorTests.CallbackFutureTest
[WARNING] Tests run: 5, Failures: 0, Errors: 0, Skipped: 3, Time elapsed: 0.035 s - in BehaviorTests.CallbackFutureTest
[INFO] Running BehaviorTests.CertificateTests
[WARNING] Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.002 s - in BehaviorTests.CertificateTests
[INFO] Running BehaviorTests.ConsumerTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5.708 s - in BehaviorTests.ConsumerTest
[INFO] Running BehaviorTests.CookieTest
[INFO] Tests run: 17, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in BehaviorTests.CookieTest
[INFO] Running BehaviorTests.CustomClientTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.18 s - in BehaviorTests.CustomClientTest
[INFO] Running BehaviorTests.CustomObjectMapperTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.023 s - in BehaviorTests.CustomObjectMapperTest
[INFO] Running BehaviorTests.DefectTest
[WARNING] Tests run: 3, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.002 s - in BehaviorTests.DefectTest
[INFO] Running BehaviorTests.DownloadProgressTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.029 s - in BehaviorTests.DownloadProgressTest
[INFO] Running BehaviorTests.ErrorParsingTest
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.032 s - in BehaviorTests.ErrorParsingTest
[INFO] Running BehaviorTests.FormPostingTest
[INFO] Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.057 s - in BehaviorTests.FormPostingTest
[INFO] Running BehaviorTests.GenericMappingTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in BehaviorTests.GenericMappingTest
[INFO] Running BehaviorTests.GZipTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.023 s - in BehaviorTests.GZipTest
[INFO] Running BehaviorTests.HeaderTest
[ERROR] Tests run: 20, Failures: 1, Errors: 0, Skipped: 1, Time elapsed: 0.071 s <<< FAILURE! - in BehaviorTests.HeaderTest
[ERROR] unicodeBasicAuth  Time elapsed: 0 s  <<< FAILURE!
org.opentest4j.AssertionFailedError: Expected Header Value Failed: Basic 44GT44KT44Gr44Gh44GvOuOBk+OCk+OBq+OBoeOBrw== ==> expected: <true> but was: <false>
        at BehaviorTests.HeaderTest.unicodeBasicAuth(HeaderTest.java:79)

[INFO] Running BehaviorTests.HostsHeaderTest
[WARNING] Tests run: 2, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.002 s - in BehaviorTests.HostsHeaderTest
[INFO] Running BehaviorTests.InterceptorTest
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.076 s - in BehaviorTests.InterceptorTest
[INFO] Running BehaviorTests.JsonPatchTest
[INFO] Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.051 s - in BehaviorTests.JsonPatchTest
[INFO] Running BehaviorTests.MetricsTest
[WARNING] Tests run: 11, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.072 s - in BehaviorTests.MetricsTest
[INFO] Running BehaviorTests.MultiPartFormPostingTest
[ERROR] Tests run: 27, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.209 s <<< FAILURE! - in BehaviorTests.MultiPartFormPostingTest
[ERROR] testPostBinaryUTF8  Time elapsed: 0.006 s  <<< FAILURE!
org.opentest4j.AssertionFailedError: Expected Query or Form value: ????? ==> expected: <true> but was: <false>
        at BehaviorTests.MultiPartFormPostingTest.testPostBinaryUTF8(MultiPartFormPostingTest.java:339)

[INFO] Running BehaviorTests.ObjectFunctionalTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.019 s - in BehaviorTests.ObjectFunctionalTest
[INFO] Running BehaviorTests.PagingTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.021 s - in BehaviorTests.PagingTest
[INFO] Running BehaviorTests.PathParamTest
[INFO] Tests run: 11, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.035 s - in BehaviorTests.PathParamTest
[INFO] Running BehaviorTests.PostRequestHandlersTest
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.029 s - in BehaviorTests.PostRequestHandlersTest
[INFO] Running BehaviorTests.ProxyTest
[WARNING] Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.001 s - in BehaviorTests.ProxyTest
[INFO] Running BehaviorTests.QueryStringTest
[INFO] Tests run: 9, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.028 s - in BehaviorTests.QueryStringTest
[INFO] Running BehaviorTests.RawUrlTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in BehaviorTests.RawUrlTest
[INFO] Running BehaviorTests.RedirectHandlingTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.029 s - in BehaviorTests.RedirectHandlingTest
[INFO] Running BehaviorTests.ResponseHeaderTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in BehaviorTests.ResponseHeaderTest
[INFO] Running BehaviorTests.ShutDownHooksTest
[ERROR] Tests run: 2, Failures: 0, Errors: 2, Skipped: 0, Time elapsed: 0.002 s <<< FAILURE! - in BehaviorTests.ShutDownHooksTest
[ERROR] canAddShutdownHooks  Time elapsed: 0 s  <<< ERROR!
java.lang.RuntimeException: java.lang.reflect.InaccessibleObjectException: Unable to make field private static java.util.IdentityHashMap java.lang.ApplicationShutdownHooks.hooks accessible: module java.base does not "opens java.lang" to unnamed module @3e9b1010
        at BehaviorTests.ShutDownHooksTest.getShutdownHookMap(ShutDownHooksTest.java:93)
        at BehaviorTests.ShutDownHooksTest.clearUnirestHooks(ShutDownHooksTest.java:78)
        at BehaviorTests.ShutDownHooksTest.setUp(ShutDownHooksTest.java:44)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private static java.util.IdentityHashMap java.lang.ApplicationShutdownHooks.hooks accessible: module java.base does not "opens java.lang" to unnamed module @3e9b1010
        at BehaviorTests.ShutDownHooksTest.getShutdownHookMap(ShutDownHooksTest.java:89)
        at BehaviorTests.ShutDownHooksTest.clearUnirestHooks(ShutDownHooksTest.java:78)
        at BehaviorTests.ShutDownHooksTest.setUp(ShutDownHooksTest.java:44)

[ERROR] ifClientsAreAlreadyRunningCanAddShutdownHooks  Time elapsed: 0 s  <<< ERROR!
java.lang.RuntimeException: java.lang.reflect.InaccessibleObjectException: Unable to make field private static java.util.IdentityHashMap java.lang.ApplicationShutdownHooks.hooks accessible: module java.base does not "opens java.lang" to unnamed module @3e9b1010
        at BehaviorTests.ShutDownHooksTest.getShutdownHookMap(ShutDownHooksTest.java:93)
        at BehaviorTests.ShutDownHooksTest.clearUnirestHooks(ShutDownHooksTest.java:78)
        at BehaviorTests.ShutDownHooksTest.setUp(ShutDownHooksTest.java:44)
Caused by: java.lang.reflect.InaccessibleObjectException: Unable to make field private static java.util.IdentityHashMap java.lang.ApplicationShutdownHooks.hooks accessible: module java.base does not "opens java.lang" to unnamed module @3e9b1010
        at BehaviorTests.ShutDownHooksTest.getShutdownHookMap(ShutDownHooksTest.java:89)
        at BehaviorTests.ShutDownHooksTest.clearUnirestHooks(ShutDownHooksTest.java:78)
        at BehaviorTests.ShutDownHooksTest.setUp(ShutDownHooksTest.java:44)

[INFO] Running BehaviorTests.TimeoutTest
[WARNING] Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.005 s - in BehaviorTests.TimeoutTest
[INFO] Running BehaviorTests.UniBodyPostingTest
[ERROR] Tests run: 18, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.003 s <<< FAILURE! - in BehaviorTests.UniBodyPostingTest
[ERROR] testPostRawBody  Time elapsed: 0 s  <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <'"@?????-test-123-0.76226762713704> but was: <'"@?????-test-123-0.76226762713704>
        at BehaviorTests.UniBodyPostingTest.testPostRawBody(UniBodyPostingTest.java:102)

[INFO] Running BehaviorTests.UploadProgressTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.005 s - in BehaviorTests.UploadProgressTest
[INFO] Running BehaviorTests.VerbTest
[INFO] Tests run: 7, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in BehaviorTests.VerbTest
[INFO] Running kong.unirest.apache.ApacheBehaviorTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.028 s - in kong.unirest.apache.ApacheBehaviorTest
[INFO] Running kong.unirest.apache.ApacheClientTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.011 s - in kong.unirest.apache.ApacheClientTest
[INFO] Running kong.unirest.apache.ApacheInterceptorTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.024 s - in kong.unirest.apache.ApacheInterceptorTest
[INFO] Running kong.unirest.apache.BaseApacheClientTest
[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.apache.BaseApacheClientTest
[INFO] Running kong.unirest.apache.ContentTypeTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.apache.ContentTypeTest
[INFO] Running kong.unirest.apache.ExampleCertificateTest
[WARNING] Tests run: 1, Failures: 0, Errors: 0, Skipped: 1, Time elapsed: 0.004 s - in kong.unirest.apache.ExampleCertificateTest
[INFO] Running kong.unirest.apache.LifeCycleTest
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 2.854 s - in kong.unirest.apache.LifeCycleTest
[INFO] Running kong.unirest.apache.SecurityConfigTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in kong.unirest.apache.SecurityConfigTest
[INFO] Running kong.unirest.apache.UtilTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.apache.UtilTest
[INFO] Running kong.unirest.BaseRequestTest
[INFO] Tests run: 12, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.BaseRequestTest
[INFO] Running kong.unirest.BodyTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in kong.unirest.BodyTest
[INFO] Running kong.unirest.ByteArrayPartTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in kong.unirest.ByteArrayPartTest
[INFO] Running kong.unirest.CacheManagerTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.CacheManagerTest
[INFO] Running kong.unirest.ClientFactoryTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.ClientFactoryTest
[INFO] Running kong.unirest.CompoundInterceptorTest
[INFO] Tests run: 8, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.051 s - in kong.unirest.CompoundInterceptorTest
[INFO] Running kong.unirest.ConfigTest
[INFO] Tests run: 24, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.07 s - in kong.unirest.ConfigTest
[INFO] Running kong.unirest.CookieParsingTest
[INFO] Tests run: 13, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in kong.unirest.CookieParsingTest
[INFO] Running kong.unirest.FilePartTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.FilePartTest
[INFO] Running kong.unirest.HeaderEntryTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.HeaderEntryTest
[INFO] Running kong.unirest.HeadersTest
[INFO] Tests run: 6, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.HeadersTest
[INFO] Running kong.unirest.HttpMethodTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in kong.unirest.HttpMethodTest
[INFO] Running kong.unirest.InputStreamPartTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in kong.unirest.InputStreamPartTest
[INFO] Running kong.unirest.JacksonObjectMapperTest
actualStr = "requestId":"c42b4c39-ad61-4896-ab8f-ca4db39b096c","headers":,"files":[],"params":,"body":null,"url":null,"queryString":null,"method":null,"routeParams":,"contentType":null,"jsonPatches":["op":"add","path":"/foo","value":"bar","op":"add","path":"/baz","value":"qux"],"status":null,"cookies":
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.014 s - in kong.unirest.JacksonObjectMapperTest
[INFO] Running kong.unirest.json.JSONArrayTest
[INFO] Tests run: 38, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in kong.unirest.json.JSONArrayTest
[INFO] Running kong.unirest.json.JSONObjectTest
[ERROR] Tests run: 55, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.002 s <<< FAILURE! - in kong.unirest.json.JSONObjectTest
[ERROR] stringToValue  Time elapsed: 0 s  <<< FAILURE!
org.opentest4j.AssertionFailedError: Wrong Error Message ==> expected: <null> but was: <Cannot invoke "String.contentEquals(java.lang.CharSequence)" because "str" is null>
        at kong.unirest.json.JSONObjectTest.stringToValue(JSONObjectTest.java:559)

[INFO] Running kong.unirest.json.JSONPointerTest
[INFO] Tests run: 23, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.003 s - in kong.unirest.json.JSONPointerTest
[INFO] Running kong.unirest.JsonNodeTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.JsonNodeTest
[INFO] Running kong.unirest.JsonObjectMapperTest
[INFO] Tests run: 27, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.JsonObjectMapperTest
[INFO] Running kong.unirest.JsonPatchItemTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.JsonPatchItemTest
[INFO] Running kong.unirest.PagedListTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.PagedListTest
[INFO] Running kong.unirest.ParamPartTest
[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s - in kong.unirest.ParamPartTest
[INFO] Running kong.unirest.PathTest
[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.001 s - in kong.unirest.PathTest
[INFO] Running kong.unirest.ResponseUtilsTest
[INFO] Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.ResponseUtilsTest
[INFO] Running kong.unirest.UnibodyStringTest
[INFO] Tests run: 4, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.UnibodyStringTest
[INFO] Running kong.unirest.UniByteArrayBodyTest
[INFO] Tests run: 2, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.UniByteArrayBodyTest
[INFO] Running kong.unirest.UriFormatterTest
[INFO] Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.002 s - in kong.unirest.UriFormatterTest
[Thread-9] INFO io.javalin.Javalin - Stopping Javalin ...
[Thread-9] INFO io.javalin.Javalin - Javalin has stopped
[INFO]
[INFO] Results:
[INFO]
[ERROR] Failures:
[ERROR]   BodyLogSummaryTest.forJsonBodies:78 expected: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
"muppet":"Gonzo"> but was: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
"muppet":"Gonzo">
[ERROR]   BodyLogSummaryTest.forObjectBodies:94 expected: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
"bar":"zip"> but was: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
"bar":"zip">
[ERROR]   BodyLogSummaryTest.forSimpleBodies:62 expected: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
this is the body> but was: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
this is the body>
[ERROR]   BodyLogSummaryTest.forSimpleGets:47 expected: <GET http://somewhere/beans?fruit=apple
Accept=image/raw
===================================> but was: <GET http://somewhere/beans?fruit=apple
Accept=image/raw
===================================>
[ERROR]   BodyLogSummaryTest.simpleFormBody:111 expected: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
album=77&band=Talking+Heads> but was: <POST http://somewhere/beans?fruit=apple
Accept=image/raw
===================================
album=77&band=Talking+Heads>
[ERROR]   HeaderTest.unicodeBasicAuth:79 Expected Header Value Failed: Basic 44GT44KT44Gr44Gh44GvOuOBk+OCk+OBq+OBoeOBrw== ==> expected: <true> but was: <false>
[ERROR]   MultiPartFormPostingTest.testPostBinaryUTF8:339 Expected Query or Form value: ????? ==> expected: <true> but was: <false>
[ERROR]   UniBodyPostingTest.testPostRawBody:102 expected: <'"@?????-test-123-0.76226762713704> but was: <'"@?????-test-123-0.76226762713704>
[ERROR]   JSONObjectTest.stringToValue:559 Wrong Error Message ==> expected: <null> but was: <Cannot invoke "String.contentEquals(java.lang.CharSequence)" because "str" is null>
[ERROR] Errors:
[ERROR]   ShutDownHooksTest.setUp:44->clearUnirestHooks:78->getShutdownHookMap:93 Runtime
[ERROR]   ShutDownHooksTest.setUp:44->clearUnirestHooks:78->getShutdownHookMap:93 Runtime
[INFO]
[ERROR] Tests run: 571, Failures: 9, Errors: 2, Skipped: 12
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for unirest 3.11.12-SNAPSHOT:
[INFO]
[INFO] unirest ............................................ FAILURE [ 25.152 s]
[INFO] unirest-java ....................................... SUCCESS [  0.018 s]
[INFO] unirest-objectmappers-gson ......................... SUCCESS [  0.018 s]
[INFO] unirest-objectmapper-jackson ....................... SUCCESS [  0.014 s]
[INFO] unirest-mocks ...................................... SUCCESS [  0.017 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  26.175 s
[INFO] Finished at: 2021-07-04T15:33:22+03:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.22.2:test (default-test) on project unirest-java: There are test failures.
[ERROR]
[ERROR] Please refer to C:\Users\Redwan\unirest-java\unirest\target\surefire-reports for the individual test results.
[ERROR] Please refer to dump files (if any exist) [date].dump, [date]-jvmRun[N].dump and [date].dumpstream.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR]   mvn <args> -rf :unirest-java```

【问题讨论】:

【参考方案1】:

构建失败,因为BanVulnerableDependencies rule for maven-enforcer-plugin 正在检查是否有任何工件存在已知漏洞。

此项目正在使用一个版本的 jetty-server (9.4.39.v20210325),其中记录了多个 CVE。

要取得进展,请将版本升级到最新版本(目前,9.4.42.v20210604 作为补丁版本,或11.0.5 整体)。这似乎不是直接依赖关系,因此您需要identify how it's being brought in。

或者,使用-Denforcer.skip 构建以跳过这些检查。

编辑:跳过 Enforcer 检查,您现在看到测试也失败了:

[ERROR] Tests run: 571, Failures: 9, Errors: 2, Skipped: 12

您可以随时build and skip tests,但这些都是项目中需要解决的问题。

【讨论】:

我执行了Denforcer.skip,但仍然出现错误。更新了错误消息的帖子【参考方案2】:

“正确”的方法可能是通过增加 pom.xml 中相关组件的版本号来解决 CVE 中提出的问题。 肮脏的方法是禁用安全检查,尽管我不确定如何。

CVE-2021-28169 CVE-2021-28169 CVE-2021-28169 CVE-2021-34428 CVE-2021-34428 CVE-2021-34428

【讨论】:

我不知道如何提高版本号。

以上是关于如何使用 Maven 安装 unirest?的主要内容,如果未能解决你的问题,请参考以下文章

当质量门失败时,如何使 Maven 构建失败?

如何在 laravel Controller 中获取 Rapidapi?

如果某个工件已经存在,如何使 Maven 构建失败

永久 Maven 安装

如何使一个 Maven 模块依赖于另一个?

Maven - POM:如何使码头端口可变,以便以后可以检索?