From 63ce0d965c9bccbd084b75d016e8ab162f94970b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Deleuze?= Date: Fri, 10 Jul 2020 12:54:53 +0200 Subject: [PATCH] Avoid field autowiring in SimpleDiscoveryClientAutoConfiguration (#786) In order to fix GraalVM compatibility --- ...impleDiscoveryClientAutoConfiguration.java | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientAutoConfiguration.java b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientAutoConfiguration.java index 170dff85..2e4188c8 100644 --- a/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientAutoConfiguration.java +++ b/spring-cloud-commons/src/main/java/org/springframework/cloud/client/discovery/simple/SimpleDiscoveryClientAutoConfiguration.java @@ -44,23 +44,29 @@ import org.springframework.core.annotation.Order; public class SimpleDiscoveryClientAutoConfiguration implements ApplicationListener { - @Autowired(required = false) private ServerProperties server; - @Value("${spring.application.name:application}") - private String serviceId; - - @Autowired private InetUtils inet; private int port = 0; private SimpleDiscoveryProperties simple = new SimpleDiscoveryProperties(); + @Autowired(required = false) + public void setServer(ServerProperties server) { + this.server = server; + } + + @Autowired + public void setInet(InetUtils inet) { + this.inet = inet; + } + @Bean @ConditionalOnMissingBean - public SimpleDiscoveryProperties simpleDiscoveryProperties() { - simple.getLocal().setServiceId(this.serviceId); + public SimpleDiscoveryProperties simpleDiscoveryProperties( + @Value("${spring.application.name:application}") String serviceId) { + simple.getLocal().setServiceId(serviceId); simple.getLocal() .setUri(URI.create( "http://" + this.inet.findFirstNonLoopbackHostInfo().getHostname()