Bar*_*urk 37 java dns spring-boot
我正在将 Spring Boot 版本从 升级2.1.x
到2.4.2
. 当我编译并运行代码时,我收到以下警告:
Unable to load io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider,fallback to system defaults. This may result in incorrect DNS resolutions on MacOS.
java.lang.ClassNotFoundException: io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider
Run Code Online (Sandbox Code Playgroud)
当我将项目部署到AWS和CentOS计算机中的DEV环境时,日志中没有此类警告消息。
谢谢,
Cur*_*lop 25
除了分类器之外,我还需要一个版本:
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<scope>runtime</scope>
<classifier>osx-x86_64</classifier>
<version>4.1.59.Final</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
范围是可选的,但分类器是必需的。
最新版本请参见: https://mvnrepository.com/artifact/io.netty/netty-resolver-dns-native-macos
示例:截至 2022 年 1 月,M1 mac 的最新版本 (aarch_64):
<classifier>osx-aarch_64</classifier>
<version>4.1.72.Final</version>
Run Code Online (Sandbox Code Playgroud)
Pet*_*Cui 14
Gradle 语法(如果您愿意):
compile "io.netty:netty-resolver-dns-native-macos:4.1.72.Final:osx-x86_64"
Run Code Online (Sandbox Code Playgroud)
对于基于 ARM 的 MacBook:
compile "io.netty:netty-resolver-dns-native-macos:4.1.72.Final:osx-aarch_64"
Run Code Online (Sandbox Code Playgroud)
小智 13
对于此拉取请求https://github.com/netty/netty/pull/10848,日志级别从“调试”更改为“警告”。
为了解决这个问题,你可以添加这个依赖:
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
如果您有 Gradle 并且只想在本地包含 netty,您可以使用https://github.com/google/osdetector-gradle-plugin
plugins {
id("com.google.osdetector") version "1.7.0"
}
dependencies {
if (osdetector.arch.equals("aarch_64")) {
implementation("io.netty:netty-all")
}
}
Run Code Online (Sandbox Code Playgroud)
正如本期所讨论的,它主要发生在使用 Apple Silicon 在 macOS 上进行本地开发期间。
如果您使用 Maven,则在project
标签下添加以下内容pom.xml
应该可以解决问题:
<profiles>
<profile>
<id>macos-m1</id>
<activation>
<os>
<family>mac</family>
<arch>aarch64</arch>
</os>
</activation>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<classifier>osx-aarch_64</classifier>
</dependency>
</dependencies>
</profile>
</profiles>
Run Code Online (Sandbox Code Playgroud)
这可确保配置文件仅针对具有 ARM64 的 macOS 激活。