1

I want to change application.properties values when my Spring Boot application is loaded. I want to change below properties when application is loaded.

From

 spring.datasource.username=root
 spring.datasource.password=encrypted password

To

spring.datasource.username=root 
spring.datasource.password=XYZ //decrypted password

Password will be stored in encrypted form and when application is loaded, I would like to decrypt and set decrypted password.

I'm able to get application properties values, but how to modify it and set back

@Bean
ApplicationRunner applicationRunner(Environment environment) {
    return args -> {
        System.out.println( environment.getProperty("spring.datasource.username"));
        //how to set decrypted password here
    };
}
Mark Rotteveel
  • 90,369
  • 161
  • 124
  • 175
Bharath Varma
  • 51
  • 1
  • 6

0 Answers0