I'm working on to retrieve a password using cyberarc API
before configuring data source in SpringBoot
.
I tried to call password retrieval API in main class before run()
but did not help, here is my code:
//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;
}
}
I am expecting to set the CyberarcPassword before calling data source bean.