프로그래밍/Spring

[Spring] mac M1에서 Spring Boot 오류 - Unable to load io.netty.resolver.dns.macos

@코린이 2023. 8. 8. 15:26

문제 배경

Spring Boot로 테스트를 돌리던 중 아래와 같은 에러가 발생했다. 

[in @coroutine#1] 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

MacOS에서 netty 관련 dependency를 추가해줘야 한다는 에러이다.

사실 실행이 정상적으로 잘 되기 때문에 큰 이슈는 아니었지만

그래도 계속 발생하니 뭔가 찝찝해서 찾아보았다.

 

문제 해결

build.gradle에 netty-resolver-dns-native-macos를 추가해주어야 한다고 한다.

developmentOnly("io.netty:netty-resolver-dns-native-macos:4.1.68.Final:osx-aarch_64")

 

그러나 해당 build는 macOS가 아닌 사람들에게도 적용되므로 아래와 같이 적용한다.

github netty issue에서 발견.

github netty issue

val isMacOS: Boolean = System.getProperty("os.name").startsWith("Mac OS X")
    val architecture = System.getProperty("os.arch").lowercase()
    if (isMacOS && architecture == "aarch64") {
        developmentOnly("io.netty:netty-resolver-dns-native-macos:4.1.68.Final:osx-aarch_64")
    }

test 돌릴 때 또 발생해서 developmentOnly 대신 testImplementation 을 추가로 넣어주었다.

깨끗하게 해결!

 

 

출처: https://github.com/netty/netty/issues/11020#issuecomment-1193280582

 

참고: https://junho85.pe.kr/2054