Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package cc.serviceops.config;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.context.annotation.Bean;
- import org.springframework.context.annotation.Configuration;
- import org.springframework.context.annotation.PropertySource;
- import org.springframework.core.env.Environment;
- import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
- import org.springframework.jdbc.datasource.DriverManagerDataSource;
- import org.springframework.transaction.annotation.EnableTransactionManagement;
- import javax.sql.DataSource;
- @Configuration
- @PropertySource("classpath:application.properties")
- @EnableTransactionManagement
- @EnableJpaRepositories("cc.serviceops")
- public class DatabaseConfig {
- private Environment environment;
- @Autowired
- public void setEnvironment(Environment environment) {
- this.environment = environment;
- }
- @Bean
- public DataSource getDataSource() {
- DriverManagerDataSource dataSource = new DriverManagerDataSource();
- dataSource.setDriverClassName(environment.getProperty("spring.datasource.driver-class-name"));
- dataSource.setUrl(environment.getProperty("spring.datasource.url"));
- dataSource.setUsername(environment.getProperty("spring.datasource.username"));
- dataSource.setPassword(environment.getProperty("spring.datasource.password"));
- return dataSource;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement