Search code examples
spring-bootkubernetesspring-cloud

How to exclude @ConfigurationProperties from reloading in kubernetes configMap


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


Solution

  • 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.