Reputation: 442
I would like to change the expected property name in Spring for data source from:
spring.datasource.url: jdbc:oracle:thin:@127.0.0.1:151:xe
to:
com.foo.bar.spring.datasource.url: jdbc:oracle:thin:@127.0.0.1:151:xe
i.e. have a certain prefix for all spring properties in my application.
Is that possible? If so, how.
Thanks in advance!
Upvotes: 1
Views: 1303
Reputation: 53
Write a configuration class where you instantate your DataSource per @Bean annotation like this:
@Configuration
public MyConfig {
@Bean(name = "dataSource")
@ConfigurationProperties(prefix = "com.foo.bar.spring.datasource")
public DataSource dataSource() {
DataSource dataSource = DataSourceBuilder.create().build();
return dataSource;
}
}
this should do the trick..
Upvotes: 1