How to exclude @ConfigurationProperties from reloading in kubernetes configMap

9/8/2020

In my application I have ds bean with prefix so I can defined it in application.properties by profile

@Bean
@ConfigurationProperties(prefix = "atomikos.db")
public AbstractDataSourceBean dbDataSource() {
    AtomikosNonXADataSourceBean atomikosDataSource = new AtomikosNonXADataSourceBean();    
    return atomikosDataSource;
}

according this article this bean will be reload when configMap changed but how I can exclude it and still use application.properties to define properties this bean according to profile ? In production system I just can not recreate connection to db

-- hudi
kubernetes
spring-boot
spring-cloud

1 Answer

9/8/2020

According to the latest documentation, you should set

spring.cloud.refresh.never-refreshable=my.package.ClassName

where my.package.ClassName is the type of bean you don't want refreshed.

-- spencergibb
Source: StackOverflow