Created
August 9, 2020 21:44
-
-
Save legarnica/40b0d8b2674647b7e7177f0b7aaabbc8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package cl.lherrera.configuracion; | |
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.lherrera") | |
@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("username")); | |
driverManagerDataSource.setPassword(environment.getProperty("dbpassword")); | |
driverManagerDataSource.setDriverClassName(environment.getProperty("driverClassName")); | |
return driverManagerDataSource; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment