Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mac apple silicon设备(M1/M2/M3)下项目启动报错,netty-resolver-dns-native-macos依赖不正确 #391

Open
ch1lam opened this issue Dec 26, 2023 · 7 comments

Comments

@ch1lam
Copy link

ch1lam commented Dec 26, 2023

基本信息

  • ruoyi-vue-pro 版本:1.8.3
  • cpu:M2 Pro
  • 操作系统:Mac OS X 13.6.2
  • 数据库:mysql 5.7

原因

redis的间接依赖中有一个netty-resolver-dns-native-macos依赖,依赖的默认版本是x86的,不支持arrch64。
在gitee找到相同问题——Mac M1芯片启动报错
怀疑是这个commit导致这个bug再次复现

复现步骤

在idea中直接启动

报错信息

2023-12-26 10:56:25.236 | ERROR 75819 | main [TID: N/A] i.n.r.d.DnsServerAddressStreamProviders  
| Unable to load io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider, fallback to system defaults. This may result in incorrect DNS resolutions on MacOS. 
Check whether you have a dependency on 'io.netty:netty-resolver-dns-native-macos'. Use DEBUG level to see the full stack: java.lang.UnsatisfiedLinkError: failed to load the required native library
image

解决办法

方法一

yudao-spring-boot-starter-redis包中的pom.xml文件加上netty-all依赖

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
    <version>4.1.79.Final</version>
</dependency>

方法二

修改yudao-spring-boot-starter-redis包中的pom.xml文件,通过<scope>标签控制运行与测试阶段指定arrch64版本的依赖

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-resolver-dns-native-macos</artifactId>
    <scope>runtime</scope>
    <classifier>osx-aarch_64</classifier>
</dependency>

方法三

修改yudao-spring-boot-starter-redis包中的pom.xml文件,直接排除依赖,重新引入arrch64版本的依赖

<dependency>
    <groupId>org.redisson</groupId>
    <artifactId>redisson-spring-boot-starter</artifactId>
    <exclusions>
        <exclusion>
            <groupId>io.netty</groupId>
            <artifactId>netty-resolver-dns-native-macos</artifactId>
        </exclusion>
    </exclusions>
</dependency>

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-resolver-dns-native-macos</artifactId>
    <scope>runtime</scope>
    <classifier>osx-aarch_64</classifier>
</dependency>

方法四

修改yudao-spring-boot-starter-redis包中的pom.xml文件,通过修改profile属性,在macos、aarch64架构下,运行与编译阶段使用arrch64的依赖包。本人使用idea自带maven时,profile自动激活不生效,尚不清楚是否与idea的maven配置有关

<profiles>
    <profile>
        <id>Apple Silicon</id>
        <activation>
            <os>
                <family>mac</family>
                <arch>aarch64</arch>
            </os>
        </activation>
        <!-- 解决apple silicon架构本地调试时出现版本错误的问题 -->
        <dependencies>
            <dependency>
                <groupId>io.netty</groupId>
                <artifactId>netty-resolver-dns-native-macos</artifactId>
                <scope>runtime</scope>
                <classifier>osx-aarch_64</classifier>
            </dependency>
        </dependencies>
    </profile>
</profiles>
image
@YunaiV
Copy link
Owner

YunaiV commented Dec 29, 2023

不错的建议。你比较倾向那个方案?

@ch1lam
Copy link
Author

ch1lam commented Dec 30, 2023

不错的建议。你比较倾向那个方案?

方案四,理论上应该是比较完美的,开箱即用。但是由于profiles没有自动激活,导致目前要先勾上profiles配置。
出现问题有可能是我对idea的配置理解错误或者对maven profiles配置理解错误引起的。

@YunaiV
Copy link
Owner

YunaiV commented Dec 30, 2023

理解。我其实有点纠结。

因为貌似不解决,也不影响功能的使用?

@ch1lam
Copy link
Author

ch1lam commented Dec 31, 2023

是的,这个问题的优先级不高,可以在之后有空再处理这类问题。

最后感谢作者和维护者的付出:)

@ldw4033
Copy link

ldw4033 commented Jan 26, 2024

Xnip-20240126233852 我这里是可用的,使用的不是 idea 自带的maven

@ldw4033
Copy link

ldw4033 commented Jan 26, 2024

个人感觉方案一和方案四都可以

方案一 不需要 版本号

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
</dependency>

@ch1lam
Copy link
Author

ch1lam commented Jan 27, 2024

个人感觉方案一和方案四都可以

方案一 不需要 版本号

<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
</dependency>

方案一与减少依赖的这个commit有冲突,所以我认为要看作者的意思


Xnip-20240126233852 我这里是可用的,使用的不是 idea 自带的maven

如果取消勾选Apple Silicon的profile的情况下,执行maven cleanmaven reimport 后启动项目是否仍有效呢?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants