在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之前先设置CyberarcPassword。