Mac M1 jdk11 DNS错误

Mac M1芯片电脑, 项目升级到jdk11启动报错

Unable to load io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider, fallback to system defaults. This may result in incorrect DNS resolutions on MacOS.

错误详细信息如下

2022-11-30 15:04:29.348 ERROR 70279 --- [           main] 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.

java.lang.reflect.InvocationTargetException: null
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) ~[na:na]
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) ~[na:na]
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na]
	at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[na:na]
	at io.netty.resolver.dns.DnsServerAddressStreamProviders.(DnsServerAddressStreamProviders.java:64) ~[netty-resolver-dns-4.1.65.Final.jar:4.1.65.Final]
	at org.redisson.connection.MasterSlaveConnectionManager.(MasterSlaveConnectionManager.java:190) ~[redisson-3.17.1.jar:3.17.1]
	at org.redisson.connection.MasterSlaveConnectionManager.(MasterSlaveConnectionManager.java:137) ~[redisson-3.17.1.jar:3.17.1]
	at org.redisson.connection.SingleConnectionManager.(SingleConnectionManager.java:30) ~[redisson-3.17.1.jar:3.17.1]
	at org.redisson.config.ConfigSupport.createConnectionManager(ConfigSupport.java:190) ~[redisson-3.17.1.jar:3.17.1]
	at org.redisson.Redisson.(Redisson.java:67) ~[redisson-3.17.1.jar:3.17.1]
	at org.redisson.Redisson.create(Redisson.java:108) ~[redisson-3.17.1.jar:3.17.1]
	......

https://github.com/netty/netty/pull/10848

解决方式,添加如下jar包:

<dependency>
  <groupId>io.nettygroupId>
  <artifactId>netty-resolver-dns-native-macosartifactId>
  <version>4.1.75.Finalversion>
  <classifier>osx-aarch_64classifier>
  <scope>runtimescope>
dependency>

如果仅在macOS上本地运行应用程序时遇到此问题,则可以为特定的Maven配置文件添加依赖项,例如“本地”。

    <profiles>
        <profile>
            <id>localid>
            <activation>
                <os>
                    
                    <name>Mac OSname>
                    <family>Macfamily>
                    
                    <arch>aarch_64arch>
                    
                    <version>9.6version>
                os>
            activation>
            <dependencies>
                <dependency>
                    <groupId>io.nettygroupId>
                    <artifactId>netty-resolver-dns-native-macosartifactId>
                    <version>${netty.version}version>
                    <scope>runtimescope>
                    <classifier>osx-aarch_64classifier>
                dependency>
            dependencies>
        profile>
    profiles>

family 的值是 Windows、UNIX 或 Mac。

name 为操作系统名称。

arch为操作系统的架构。

version为操作系统的版本。

具体的值可以通过查看环境中的系统属性“os.name”“os.arch”和“os.version”获取

你可能感兴趣的:(Java基础,macos,java)