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 - 无法初始化插件
- Eclipse 插件更新错误日志在哪里? 2022-01-01
- 从 finally 块返回时 Java 的奇怪行为 2022-01-01
- Spring Boot连接到使用仲裁器运行的MongoDB副本集 2022-01-01
- 将log4j 1.2配置转换为log4j 2配置 2022-01-01
- Java包名称中单词分隔符的约定是什么? 2022-01-01
- C++ 和 Java 进程之间的共享内存 2022-01-01
- value & 是什么意思?0xff 在 Java 中做什么? 2022-01-01
- 如何使用WebFilter实现授权头检查 2022-01-01
- Jersey REST 客户端:发布多部分数据 2022-01-01
- Safepoint+stats 日志,输出 JDK12 中没有 vmop 操作 2022-01-01