UnsatisfiedLinkError

运行的电脑: mac 使用的是m1 芯片
IDEA 配置的 JDK 是 zulu 8 的版本。

异常信息

Exception in thread "main" java.lang.UnsatisfiedLinkError: /Users/mi/Library/Caches/JNA/temp/jna1009468612144095833.tmp: dlopen(/Users/mi/Library/Caches/JNA/temp/jna1009468612144095833.tmp, 0x0001): tried: '/Users/mi/Library/Caches/JNA/temp/jna1009468612144095833.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/mi/Library/Caches/JNA/temp/jna1009468612144095833.tmp' (no such file), '/Users/mi/Library/Caches/JNA/temp/jna1009468612144095833.tmp' (fat file, but missing compatible architecture (have 'i386,x86_64', need 'arm64'))

原因

m1 芯片运行中使用到jna相关依赖时依赖包发生的错误

  
<dependency>  
    <groupId>net.java.dev.jnagroupId>  
    <artifactId>jnaartifactId>  
    <version>5.5.0version>  
dependency>  
<dependency>  
    <groupId>net.java.dev.jnagroupId>  
    <artifactId>jna-platformartifactId>  
    <version>5.5.0version>  
dependency>

解决方案

使用 jna 和 jna-platform 5.7 版本及以上的包,只有5.7及以上的包对arm64架构有适配

<dependency>  
    <groupId>net.java.dev.jnagroupId>  
    <artifactId>jnaartifactId>  
    <version>5.13.0version>  
dependency>  
  
<dependency>  
    <groupId>net.java.dev.jnagroupId>  
    <artifactId>jna-platformartifactId>  
    <version>5.13.0version>  
dependency>

你可能感兴趣的:(mac,IDEA,macos)