Spring脱离应用环境配置变量

1. 定义变量属性文件D:\ronghui_config\config\cpm\param.properties

备注:一定要在properties文件中&写为&因为在xml文件中不识别&,必须是&amp
2.设定应用运行时环境变量-DRH_HOME=”D:\ronghui_config”, ecli[se的tomcat设定VM agrument, 或者catalina.bat设定JAVA_OPTS……….
3.Spring配置PropertyPlaceholderConfigurer

Spring的PropertyPlaceholderConfigurer应用 http://blog.csdn.net/u010150082/article/details/11201035, PropertyPlaceholderConfigurer起的作用就是将占位符指向的数据库配置信息放在bean中定义的工具。如果在指定的Properties文件中找不到你想使用的属性,它还会在Java的System类属性中查找。 我们可以通过System.setProperty(key, value)或者java中通过-Dnamevalue来给Spring配置文件传递参数。
另外一种加载的方式属性文件为:

4. 使用:
A: applicationContext.xml使用参数:

B:源码使用注解方式 :

注意:这两种方法可以同时使用