0

In our team, we agreed that we are gonna use all of the configurations as a code (let's Say AppConfiguration class) i.e :

@Value("${spring.datasource.url:jdbc:postgresql://localhost:5432/postgres}");
private String jdbcUrl;

and later use them to configure beans with this value:

@Bean
@Primary
@ConfigurationProperties(prefix = "spring.datasource.configuration")
public DataSource teamDataSource() {
        return dataSourceProperties().initializeDataSourceBuilder().build();
}

@Bean
@Primary
public DataSourceProperties telemetryControlServiceDataSourceProperties() {
    DataSourceProperties dataSourceProperties = new DataSourceProperties();
    dataSourceProperties.setUrl(appConfig.getJdbcUrl());
....
    return dataSourceProperties;
}

My Question: As configuration properties rise, I can't put anything in application.properties files per our agreement, and I have to search for pojos for @ConfigurationProperties which I could not find sometimes. Is there a general/universal way for exposing all kinds of configuration properties from applications.properties? I.e I'm able to find some of the actuator properties, but most of them I cannot:

management.endpoints.web.base-path=/debug
management.endpoints.web.exposure.include=*
management.endpoints.web.exposure.exclude=env,beans
management.endpoint.health.show-details=always
management.endpoint.metrics.enabled=true
management.endpoint.prometheus.enabled=true
management.endpoint.loggers.enabled=true
Kostov
  • 45
  • 8
  • I can't understand what you want to do, you have properties file with values and you want to access these properties in the code ? – user2304483 May 19 '23 at 03:29
  • Hi, thanks for the response! What I'm trying to do is to keep my application.properties absolutely clean, without any properties there. With most of the cases until now, I'm able to find a way to expose the specific configuration bean, instead of writing into the properties file, but I found it very difficult for some conf beans, as I'm unable to 'browse' all of the spring beans. So I'm searching a universal way to configure these properties, without adding them to app.properties file. Thanks! – Kostov May 22 '23 at 08:12

0 Answers0