Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.sql.DataSource;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.context.annotation.Bean;
- 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("cl.adl.profe")
- @PropertySource("classpath:database.properties")
- public class AppConfig {
- @Autowired
- Environment environment;
- @Bean
- 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