I'm upgrading my Spring Boot version from 2.1.x
to 2.4.2
. When I compiled and run the code, I got the following warning:
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
When I deploy the project to DEV environment which is in AWS and CentOS machine, there is no such warning message in the logs.
Thanks,
I needed a version in addition to classifier:
<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>
scope is optional but classifier is required.
For the latest version, see: https://mvnrepository.com/artifact/io.netty/netty-resolver-dns-native-macos
Example: Latest version for M1 macs (aarch_64), as of 2022-01:
<classifier>osx-aarch_64</classifier>
<version>4.1.72.Final</version>
For this pull request https://github.com/netty/netty/pull/10848, the log level changes from "debug" to "warn."
To solve this problem, you can add this dependency:
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
</dependency>
Gradle syntax if you prefer:
compile "io.netty:netty-resolver-dns-native-macos:4.1.72.Final:osx-x86_64"
and for ARM-based macbook:
compile "io.netty:netty-resolver-dns-native-macos:4.1.72.Final:osx-aarch_64"
As suggested here, add the following dependency in your module.
<properties>
<version.netty>4.1.59.Final</version.netty>
</properties>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<version>${version.netty}</version>
<scope>runtime</scope>
<classifier>osx-x86_64</classifier>
</dependency>
If you face this issue only while running your app locally on macOS, you may add the dependency for a specific maven profile, e.g. "local".
<profiles>
<profile>
<id>local</id>
<dependencies>
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-resolver-dns-native-macos</artifactId>
<version>${version.netty}</version>
<scope>runtime</scope>
<classifier>osx-x86_64</classifier>
</dependency>
</dependencies>
</profile>
</profiles>
You can avoid specifying version
if you import netty-bom in dependencyManagement
.
If you have Gradle and want to include netty only locally you can make use of 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")
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With