我通过数据库中的keystore
在Spring WS中加载JPA
。
@Bean(name = "keyStore")
@Primary
KeyStoreFactoryBean keyStore() throws Exception {
try {
KeyStore keyStore = keyService.keyStore();
KeyStoreFactoryBean keyStoreFactory = new KeyStoreFactoryBean();
keyStoreFactory.setPassword(keyStore.getPassword());
keyStoreFactory.setLocation(keyStore.asResource());
keyStoreFactory.afterPropertiesSet();
return keyStoreFactory;
} catch (Exception e) {
throw e;
}
}
此代码有效,但如果我更新数据库中的密钥库记录,则KeyStoreFactoryBean
不会重新加载(显然)。我知道bean的scope
anotation但不确定scope
最适合这种情况的是什么?
如何"重新加载"每次更改数据库记录时该bean是什么?