0

I have written a Spring Boot + Spring Data + JPA Java web application.

It uses username/password authentication to SQL server. The password expires on a schedule and needs reset often.

I have a password safe API available so I can call that and get the password dynamically at any time.

@Configuration
public class DatasourceConfiguration {

    @Value("${jdbc.url}")
    private String jdbcUrl;

    @Value("${jdbc.driverClassName}")
    private String driverClassName;

    @Value("${jdbc.username}")
    private String username;

    @Value("${jdbc.password}")
    private String password;

    @Bean
    public DataSource dataSource() {
        BasicDataSource ds = new BasicDataSource();
        ds.setDriverClassName(driverClassName);
        ds.setUrl(jdbcUrl);
        if (!jdbcUrl.contains(";integratedSecurity=true")) {
            ds.setUsername(username);
            ds.setPassword(PasswordService.getPassword(username));

        }
        return ds;
    }

    @Bean
    public JpaVendorAdapter hibernateJpaVendorAdapter() {
        return new HibernateJpaVendorAdapter();
    }
}

If I redeploy the web application, it will deploy the latest password.

When I change the password in SQL, is there a way to get the bean to re-register without having to redeploy the web application archive?

TheSmith1222
  • 345
  • 1
  • 4
  • 11
Nicholas DiPiazza
  • 10,029
  • 11
  • 83
  • 152

0 Answers0