Mockito on JDK16 and Mac OS - Could not initialize plugin(JDK16 和 Mac OS 上的 Mockito - 无法初始化插件)
问题描述
java.lang.IllegalStateException: Could not initialize plugin: interface org.mockito.plugins.MockMaker (alternate: null)
Caused by: java.lang.IllegalStateException: Failed to load interface org.mockito.plugins.MockMaker implementation declared in java.lang.CompoundEnumeration@4158debd
Caused by: java.lang.reflect.InvocationTargetException
Caused by: org.mockito.exceptions.base.MockitoInitializationException:
Could not initialize inline Byte Buddy mock maker.
It appears as if your JDK does not supply a working agent attachment mechanism.
Java : 16
JVM vendor name : Oracle Corporation
JVM vendor version : 16.0.2+7-67
JVM name : Java HotSpot(TM) 64-Bit Server VM
JVM version : 16.0.2+7-67
JVM info : mixed mode, sharing
OS name : Mac OS X
OS version : 11.5
Caused by: java.lang.IllegalStateException: Could not self-attach to current VM using external process
在使用 Mockito 3.7.7 的 Maven 3.8.1 和 JDK16.02 上出现上述错误,在全新的设置中,无法弄清楚原因.我已经尝试了从 3.7 到 3.11 的每个 Mockito 版本,但无济于事.
Getting the above error on Maven 3.8.1 and JDK16.02 with Mockito 3.7.7, on a fresh setup and cannot figure out why. I have tried every Mockito version from 3.7 all the way to 3.11 to no avail.
但是,这些配置适用于 Windows 10 Pro 上基于 JDK15 的旧设置.
These configurations however works on an older setup based on JDK15 on Windows 10 Pro.
推荐答案
Mockito 核心依赖于一个名为 byte-buddy 的库,这个问题主要发生在 mockito 找不到匹配的 byte buddy jar 版本时.
Mockito core depends on a library called byte-buddy and this problem is mostly occurred when mockito doesn’t find a matching byte buddy jar version.
找出您的项目正在使用的 mockito 核心版本.在 Eclipse 中,您可以通过导航到右键单击项目->属性->Java 构建路径 ->库标签
Find out the mockito core version your project is using. In eclipse, you can check in project build path by navigating to Right click on project -> Properties -> Java build path -> Libraries tab
在 maven 存储库中搜索该版本的 mockito 核心.
Search maven repository for that version of mockito core.
查看编译依赖部分.记下 byte-buddy 的正确依赖版本并包含在项目中.如果 jar 已包含在其他版本中,请使用此正确版本覆盖该版本.
Look at the Compile Dependencies section. Note down the correct dependent version of byte-buddy and include in the project. If the jar is already included with some other version, override the version with this correct version.
构建应用程序并再次运行测试.您与 MockMaker 相关的问题现在必须解决.
Build the application and run the tests again. Your issue related to MockMaker must be solved by now.
这篇关于JDK16 和 Mac OS 上的 Mockito - 无法初始化插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:JDK16 和 Mac OS 上的 Mockito - 无法初始化插件
基础教程推荐
- 减少 JVM 暂停时间 >1 秒使用 UseConcMarkSweepGC 2022-01-01
- 设置 bean 时出现 Nullpointerexception 2022-01-01
- FirebaseListAdapter 不推送聊天应用程序的单个项目 - Firebase-Ui 3.1 2022-01-01
- 在 Libgdx 中处理屏幕的正确方法 2022-01-01
- 降序排序:Java Map 2022-01-01
- 如何使用 Java 创建 X509 证书? 2022-01-01
- Java:带有char数组的println给出乱码 2022-01-01
- Java Keytool 导入证书后出错,"keytool error: java.io.FileNotFoundException &拒绝访问" 2022-01-01
- 无法使用修饰符“public final"访问 java.util.Ha 2022-01-01
- “未找到匹配项"使用 matcher 的 group 方法时 2022-01-01