我在Spring Boot应用程序中有一个数据源配置类。下面的代码段
密码正在从服务中获取,并且当我重新启动Spring Boot应用程序(或JVM)时,密码的更改不会刷新。任何想法?
@Configuration
@EnableTransactionManagement
public class TestDBConfig
{
..............
@Value("${URL}")
private String dbURL;
.........
@Bean
@RefreshScope
public DataSource dataSource() {
DriverManagerDataSource driverManagerDataSourc = new DriverManagerDataSource();
driverManagerDataSourc.setDriverClassName(oracleDriver);
driverManagerDataSourc.setUrl(dbURL);
driverManagerDataSourc.setUsername(dbUserName);
dataSource.setPassword(dbPassword);
if (isPWService != null && isPWService.equalsIgnoreCase("N")) {
driverManagerDataSourc.setPassword(dbPassword);
} else {
driverManagerDataSourc.setPassword(getPWService());
}
return dataSource;
}
public String getPWService() {
.........
}
}