2015-02-23 56 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。