有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

基于bean id的java SpEL

我有一个springbean文件,其中包含许多ThingConfigurationResourceBean。根据系统属性activeCfg(-DactiveCfg=thing1),我想为每个bean设置active属性值,条件是bean id是否与系统属性值匹配

我不明白如何访问SpEL表达式中的bean id。这不起作用#this.id

<bean class="ThingConfigurationResource" id="thing1">
  <property name="active" value="#{systemProperties.activeCfg == #this.id ? true : false}"/>
</bean>

我得到:

Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 41): Property or field 'id' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public?

我没有访问程序源代码的权限,因此我必须使用SpEL来执行此操作


共 (0) 个答案