我想下面的代码值:DriverClassName,Url,Username,Password从读取application.properties文件,该怎么做?我正在使用 Spring Boot、Mysql、Hibernate 和 Spring Rest。
数据源配置文件
//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;
}
....
....
....
温温酱
浮云间
相关分类