spring3.0 使用@value 加载配置文件property

(1)在spring配置文件中。加入

 <beans   xmlns:context="http://www.springframework.org/schema/context">

 <context:property-placeholder location="classpath:datasource.properties,classpath:constant.properties"/>

</beans>

 

(2)

@Value("${url}")

private String url;

public static void main(String args[]){

System.out.println("url  "+url);

}

 

posted @ 2017-09-15 16:21  图生  阅读(207)  评论(0)    收藏  举报