1

我在 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() {
        .........
    }
        }
4

0 回答 0