我正在尝试使用 spring boot 2.7.3 版本和 netty 解析器 4.1.75.Final 生成令牌 在调用 AD 令牌 url 时,我遇到了打击错误
Failed to resolve 'login.microsoftonline.com' and search domain query for configured domains failed as well: [ppp.companyname.com]; nested exception is io.netty.resolver.dns.DnsResolveContext$SearchDomainUnknownHostException: Failed to resolve 'login.microsoftonline.com' and search domain query for configured domains failed as well:
build.gradle
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation("io.netty:netty-resolver-dns-native-macos:4.1.75.Final") {
artifact {
classifier = "osx-aarch_64"
}
}
生成代币类
public Mono<String> generateToken() throws URISyntaxException {
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
MultiValueMap<String, String> bodyValues = new LinkedMultiValueMap<>();
bodyValues.add("client_id",azureClientId);
bodyValues.add("client_secret",azureClientSecret);
bodyValues.add("grant_type",grantType);
return this.client.post().uri(azureUrl)
.body(BodyInserters.fromFormData(bodyValues))
.retrieve()
.bodyToMono(String.class);
}
在代理中添加 -Dvertx.disableDnsResolver=true