首页 > 其他分享 >EL1008E: Property or field 'config' cannot be found on object of type 'org.springfram

EL1008E: Property or field 'config' cannot be found on object of type 'org.springfram

时间:2023-01-06 18:36:08浏览次数:55  
标签:java type factory springframework BeanExpressionContext expression org config

EL1008E: Property or field 'config' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext'


 

1、报错信息

SpringMVC 工程改造为 SpringBoot 工程的过程中,服务报错如下:

Caused by: org.springframework.beans.factory.BeanExpressionException: Expression parsing failed; nested exception is org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'config' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public or not valid?
    at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:170)
    at org.springframework.beans.factory.support.AbstractBeanFactory.evaluateBeanDefinitionString(AbstractBeanFactory.java:1631)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1335)
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1311)
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.resolveFieldValue(AutowiredAnnotationBeanPostProcessor.java:656)
    ... 20 common frames omitted
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E: Property or field 'config' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public or not valid?
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:217)
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:104)
    at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:91)
    at org.springframework.expression.spel.ast.CompoundExpression.getValueRef(CompoundExpression.java:55)
    at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:91)
    at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:112)
    at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:273)
    at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:167)
    ... 24 common frames omitted

 

 

2、解决方案

@Value("#{config['sampling.interval']}")
改为
@Value("${sampling.interval}")

 

其中, sampling.interval 是项目中用到的一个变量。根据实际情况进行调整。

将项目中所有的变量引用,按照上述方式进行修改,即可解决上述报错问题。

 

标签:java,type,factory,springframework,BeanExpressionContext,expression,org,config
From: https://www.cnblogs.com/miracle-luna/p/17031290.html

相关文章