我有一个bean来保存一些配置:
public class CustomerService{
private Config config;
@Required
public void setConfig(Config config){
this.config = config;
}
}
public Config {
private String login;
private String password;
//setters/getters
}
app-context.xml:
<bean id="config" class="Config"/>
<bean id="customerService" class="CustomerService">
<property name="config" ref="config"/>
</bean>
配置值在运行时通过调用API获取。如何在运行时更新这些值?我可以使用setter来做吗:
customerService.getConfig().setLogin("login");