在形成数据源之前获取数据库密码

时间:2019-05-14 09:04:55

标签: java spring-boot

cyberarc API中配置数据源之前,我正在努力使用SpringBoot检索密码。

我尝试在run()之前在主类中调用密码检索API,但没有帮助,这是我的代码:

//programmatic way of building a data source.
@Configuration
@PropertySource(value = {
    "classpath:application.properties"
})
public class DataSourceConfig {

    @Autowired
    Environment environment;

    private CyberarcPassword CyberarcPassword;

    private static final Logger log = LoggerFactory.getLogger(DataSourceConfig.class);

    @Bean
    public DataSource dataSource() {    
        final DriverManagerDataSource dataSource = new DriverManagerDataSource();    
        dataSource.setDriverClassName(environment.getProperty("spring.datasource.driver-class-name"));    
        dataSource.setUrl(environment.getProperty("spring.datasource.url"));    
        dataSource.setUsername(environment.getProperty(CyberarcPassword.getUsername()));    
        dataSource.setPassword(environment.getProperty(CyberarcPassword.getPassword()));

        return dataSource;    
    }
}

我希望在调用数据源bean之前先设置Cyber​​arcPassword。

0 个答案:

没有答案