Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.latam.jpacrud;
- import javax.sql.DataSource;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.context.annotation.ComponentScan;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.context.annotation.PropertySource;
- import org.springframework.core.env.Environment;
- import org.springframework.jdbc.datasource.DriverManagerDataSource;
- @Configuration
- @ComponentScan("com.latam.jpacrud")
- @PropertySource("classpath:database.properties")
- public class AppConfig {
- @Autowired
- Environment environment;
- DataSource dataSource() {
- DriverManagerDataSource driverManagerDataSource = new DriverManagerDataSource();
- driverManagerDataSource.setUrl(environment.getProperty("url"));
- driverManagerDataSource.setUsername(environment.getProperty("dbuser"));
- driverManagerDataSource.setPassword(environment.getProperty("dbpassword"));
- driverManagerDataSource.setDriverClassName(environment.getProperty("driver"));
- return driverManagerDataSource;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement