I want the below code values: DriverClassName, Url, Username, Password to be read from application.properties file, how to do that? I am using Spring Boot, Mysql, Hibernate and Spring Rest.
DatasourceConfig.java
//This is working fine with inline value specified as below (DriverClassName, Url,Username,Password
@Configuration
@EnableTransactionManagement
@EnableJpaRepositories(basePackages = "com.nouhoun.springboot.jwt.integration.repository")
public class DatasourceConfig {
@Bean
public DataSource datasource() throws PropertyVetoException {
final DriverManagerDataSource dataSource = new DriverManagerDataSource();
dataSource.setDriverClassName("com.mysql.jdbc.Driver");
dataSource.setUrl("jdbc:mysql://localhost:3306/fdb?createDatabaseIfNotExist=true");
dataSource.setUsername("root");
dataSource.setPassword("");
return dataSource;
}
....
....
....