Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SpringBootApplication
- @EnableConfigurationProperties
- @ComponentScan
- public class MyApplication {
- @Bean(name="dmDs")
- @ConfigurationProperties("spring.datasource")
- public DataSource dmDataSource(){
- return DataSourceBuilder.create().build();
- }
- @Bean
- public String aBean(){
- DataSource ds = dmDataSource(); // creates a datasource with URL, username and password empty.
- return new String("");
- }
- spring:
- profiles: test
- datasource:
- url: jdbc:oracle:thin:SOME_URL
- driver-class-name: oracle.jdbc.OracleDriver
- password: test
- username: test
- [main] o.s.c.e.PropertySourcesPropertyResolver : Found key 'spring.datasource.url' in [applicationConfig: [classpath:/application.yml]] with type [String]
- [main] o.s.c.e.PropertySourcesPropertyResolver : Found key 'spring.datasource.driver-class-name' in [applicationConfig: [classpath:/application.yml]] with type [String]
- [main] o.s.c.e.PropertySourcesPropertyResolver : Found key 'spring.datasource.password' in [applicationConfig: [classpath:/application.yml]] with type [String]
- [main] o.s.c.e.PropertySourcesPropertyResolver : Found key 'spring.datasource.username' in [applicationConfig: [classpath:/application.yml]] with type [String]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement