在我的 Apple M1 笔记本电脑上,我尝试运行 Spring Boot,但收到错误:
java.lang.UnsatisfiedLinkError: no zstd-jni in java.library.path: /Users/me/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Unsupported OS/arch, cannot find /darwin/aarch64/libzstd-jni.dylib or load zstd-jni from system libraries. Please try building from source the jar or providing libzstd-jni in your system.
在 Mac 上,我没有
/darwin/aarch64/
文件夹,并且找不到安装或下载的位置 libzstd-jni.dylib
。
我通过 Arm 64 DMG 安装程序安装了 Java
$ java -version
- java version "17.0.2" 2022-01-18 LTS
- Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)
- Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, sharing)
JDK中的
MasOS文件夹下有一个
libjli.dylib
文件:
/Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/MacOS/libjli.dylib
我将
libjli.dylib
添加到 /Library/Java/Extensions/
,但这没有帮助。
我别无选择。如果有人可以帮助我,我将非常感激。
这是官方存储库:https://github.com/luben/zstd-jni
在二进制版本中我看到对 aarch64 的支持。我会尝试升级到最新版本:
implementation 'com.github.luben:zstd-jni:1.5.2-1'
(我没有这种问题,这只是一个猜测——如果有帮助请告诉我。)
我在运行单元测试时遇到了同样的问题:
Exception in thread "pool-3-thread-1" java.lang.UnsatisfiedLinkError: no zstd-jni-1.5.6-7 in java.library.path: /Users/<user>/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.
Unsupported OS/arch, cannot find /darwin/aarch64/libzstd-jni-1.5.6-7.dylib or load zstd-jni-1.5.6-7 from system libraries. Please try building from source the jar or providing libzstd-jni-1.5.6-7 in your system.
at java.base/java.lang.ClassLoader.loadLibrary(Unknown Source)
at java.base/java.lang.Runtime.loadLibrary0(Unknown Source)
at java.base/java.lang.System.loadLibrary(Unknown Source)
at com.github.luben.zstd.util.Native$1.run(Native.java:71)
at com.github.luben.zstd.util.Native$1.run(Native.java:69)
at java.base/java.security.AccessController.doPrivileged(Unknown Source)
at com.github.luben.zstd.util.Native.loadLibrary(Native.java:69)
at com.github.luben.zstd.util.Native.load(Native.java:124)
at com.github.luben.zstd.util.Native.load(Native.java:89)
at com.github.luben.zstd.ZstdInputStreamNoFinalizer.<clinit>(ZstdInputStreamNoFinalizer.java:23)
at com.github.luben.zstd.ZstdInputStream.<init>(ZstdInputStream.java:24)
at com.amazon.mobile.ssnap.clientstore.filestore.FileStoreImpl$4.call(FileStoreImpl.java:794)
at com.amazon.mobile.ssnap.clientstore.filestore.FileStoreImpl$4.call(FileStoreImpl.java:680)
at bolts.Task$4.run(Task.java:357)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.base/java.lang.Thread.run(Unknown Source)
我忘记将 testImplementation 作为我的 build.gradle 依赖项的一部分包含在内,这解决了我的问题:
dependencies {
implementation "com.github.luben:zstd-jni:VERSION@aar"
testImplementation "com.github.luben:zstd-jni:VERSION"
}
https://github.com/luben/zstd-jni?tab=readme-ov-file#android-support