spring EL表达式的简单使用

 时间:2024-10-14 06:20:39

1、项目加载中读取配置文件:<context-param> <param-name>contextConfigLocation</param-name> <param-value> classpath*:spring/spring_*.xml, classpath:kernel/dubboProvider/All.xml </param-value> </context-param>

spring EL表达式的简单使用

2、还需要配置 <listener> <listener-class> org.springframework.web.context.ContextLoaderListene </listener-class> </listener>

spring EL表达式的简单使用

3、在ContextLoaderListener加载时,会查找名为contextConfigLocation的参数。因此,配置<context-param>时参数名字应该是contextConfigLocation。

spring EL表达式的简单使用

4、<!-- 引入配置文件 --> <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="fileEncoding" value="UTF-8" /> <property name="ignoreUnresolvablePlaceholders" value="true" /> <property name="locations"> <list> <value>classpath:redis.properties</value>

spring EL表达式的简单使用

5、 <value>classpath:servi罕铞泱殳ceToken.properties&造婷用痃lt;/value> <value>classpath:config.properties</value> <value>classpath:reconciliation.properties</value> </list> </property> </bean>引入propertyConfigurer,并生成实体,这里就可以在任意地方使用springel表达式了

spring EL表达式的简单使用

6、@Value("${weixin.appId}") private String appId; @Value("${weixin.order}") private String orderUrl; @Value("${weixin.mergeOrderUrl}")直接使用$获取。但是要和配置文件对应。

spring EL表达式的简单使用

7、generalPay.remote.port=${general.pay.remote.port}weixin.secret=${filter.weixin.secret}weixin.appId=${filter.weixin.appId}

spring EL表达式的简单使用
  • 易语言-关于使用拖放组件的方法
  • iso镜像文件如何安装?也是bin文件的安装方法
  • veket操作系统的安装方法(windows7篇)
  • ubuntu16.04安装mate桌面
  • 热门搜索
    好看的手抄报花边 黑白手抄报图片 军训的手抄报 小学五年级手抄报 创文明城市手抄报资料 消防知识手抄报内容 三月文明礼貌月手抄报 爱的教育手抄报图片 中秋手抄报图片大全 未来的学校手抄报