多语言展示
当前在线:1644今日阅读:27今日分享:41

spring EL表达式的简单使用

spring EL的使用
方法/步骤
1

项目加载中读取配置文件:        contextConfigLocation                    classpath*:spring/spring_*.xml,            classpath:kernel/dubboProvider/All.xml           

2

还需要配置               org.springframework.web.context.ContextLoaderListene      

3

在ContextLoaderListener加载时,会查找名为contextConfigLocation的参数。因此,配置时参数名字应该是contextConfigLocation。

4

                                                        classpath:redis.properties

5

classpath:serviceToken.properties                classpath:config.properties                classpath:reconciliation.properties                        引入propertyConfigurer,并生成实体,这里就可以在任意地方使用springel表达式了

6

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

7

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

方法/步骤2

最后在pom.xml配置参数信息,即可。

推荐信息