spring读取propertyes 新方法

<context:property-placeholder location="classpath:mysql.properties"/>
    
<util:properties id="settings" location="classpath:webConfig.properties"></util:properties>

Bean里要加入

xmlns:util="http://www.springframework.org/schema/util"

http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-3.1.xsd

 

@Component("webConfig")
public class WebConfig {
    
    @Value("#{settings['web.version']}")
    private String webVersion;

    public String getWebVersion() {
        return webVersion;
    }
    
}
        @Autowired
    private WebConfig webConfig;

        webConfig.getWebVersion();    

 

posted on 2013-07-08 09:07  游鱼  阅读(489)  评论(0编辑  收藏  举报