Guest User

Untitled

a guest
Aug 14th, 2018
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.66 KB | None | 0 0
  1. @Configuration
  2. @ImportResource("classpath:/com/acme/properties-config.xml")
  3. public class AppConfig {
  4.   private @Value("${jdbc.url}") String url;
  5.   private @Value("${jdbc.username}") String username;
  6.   private @Value("${jdbc.password}") String password;
  7.  
  8.   public @Bean DataSource dataSource() {
  9.       return new DriverManagerDataSource(url, username, password);
  10.   }
  11. }
  12. /*---------------------------------*/
  13. properties-config.xml
  14. <beans>
  15.   <context:property-placeholder location="classpath:/com/acme/jdbc.properties"/>
  16. </beans>
  17.  
  18. /*---------------------------------*/
  19. jdbc.properties
  20. jdbc.url=jdbc:hsqldb:hsql://localhost/xdb
  21. jdbc.username=sa
  22. jdbc.password=
Add Comment
Please, Sign In to add comment