Reputation: 42849
With the release of the Brixton Release Train, I have noticed that there has been an update to the EurekaInstanceConfigBean
interface, specifically, the default constructor has been made private
, and a new constructor has been introduced that takes in an instance of org.springframework.cloud.commons.util.InetUtils
.
With the Angel Release Train, many examples online (cloud.spring.io included) showed that this bean was configured similar to the following when working within AWS:
@Bean
@Profile("!default")
public EurekaInstanceConfigBean eurekaInstanceConfig() {
EurekaInstanceConfigBean b = new EurekaInstanceConfigBean();
AmazonInfo info = AmazonInfo.Builder.newBuilder().autoBuild("eureka");
b.setDataCenterInfo(info);
return b;
}
I understand that I can probably get this to work by creating an instance of InetUtils
and providing that to the constructor, but I am more curious about the best practices for creating this @Bean
and configuring it to work with AWS.
Is the intent to just create the instance of InetUtils
, or utilize AutoConfiguration, or a specific @Enable*
annotation, or even just set the field in a @PostConstruct
method? Something else perhaps?
Upvotes: 2
Views: 1621
Reputation: 25147
InetUtils
is a bean, simply inject it.
public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils) {
EurekaInstanceConfigBean b = new EurekaInstanceConfigBean(inetUtils);
//...
return b;
}
The bean comes from AutoConfiguration, specifically, the org.springframework.cloud.commons.util.UtilAutoConfiguration
class, which is a part of spring-cloud-commons jar.
Upvotes: 3