2015-02-23 71 views

回答

1

有没有办法改变的春天bean定义的属性在运行时间。但你可以在preparation.You期间动态添加的属性可以覆盖PropertyPlaceholderConfigurer这样,

public class SpringPropertiesLoader extends PropertyPlaceholderConfigurer { 

@Override 
protected void loadProperties(Properties props) throws IOException { 
    super.loadProperties(props); 
    props.put("myProp","myValue"); 
} 
} 

,然后,使用该类,而不是Spring xml中的PropertyPlaceholderConfigurer。