spring同时使用aop和spel表达式出错:Property or field 'instrument' cannot be found on object of type 'com.sun.pr
2016-08-10 12:18
1686 查看
错误信息:
Caused by: org.springframework.expression.spel.SpelEvaluationException: EL1008E:(pos 6): Property or field 'instrument' cannot be found on object of type 'com.sun.proxy.$Proxy2' - maybe not public? at org.springframework.expression.spel.ast.PropertyOrFieldReference.readProperty(PropertyOrFieldReference.java:224) at org.springframework.expression.spel.ast.PropertyOrFieldReference.getValueInternal(PropertyOrFieldReference.java:94) at org.springframework.expression.spel.ast.PropertyOrFieldReference.access$000(PropertyOrFieldReference.java:46) at org.springframework.expression.spel.ast.PropertyOrFieldReference$AccessorLValue.getValue(PropertyOrFieldReference.java:374) at org.springframework.expression.spel.ast.CompoundExpression.getValueInternal(CompoundExpression.java:88) at org.springframework.expression.spel.ast.SpelNodeImpl.getValue(SpelNodeImpl.java:120) at org.springframework.expression.spel.standard.SpelExpression.getValue(SpelExpression.java:242) at org.springframework.context.expression.StandardBeanExpressionResolver.evaluate(StandardBeanExpressionResolver.java:161) ... 23 more
由于aop是默认创建的代理是基于接口的,不能访问类的方法。performer接口中只有一个perform方法,所以会报错:
Property or field 'instrument' cannot be found on object of type 'com.sun.proxy.$Proxy2' -
解决此问题,只需要在aop:config中加上
proxy-target-class="true"就行了
<aop:config proxy-target-class="true"> <aop:aspect ref="log"> <aop:pointcut id="perform" expression="execution(* algo.study.spring.xmlbean.Performer.perform(..))" /> <aop:before pointcut-ref="perform" method="start" /> <aop:after pointcut-ref="perform" method="end" /> </aop:aspect> </aop:config>
相关文章推荐
- spring同时使用aop和spel表达式出错:Property or field 'instrument' cannot be found on object of type 'com.sun.pr
- Property or field 'str' cannot be found on object of type 'com.yubai.EL.DemoService' - maybe not pub
- 【spring-security】 Property or field 'ROLE_USER' cannot be found on object of type 'org.springframewo
- 错误:Property or field 'default' cannot be found on object of type 'com.netflix.appinfo.InstanceInfo'
- Property or field 'siteUrl' cannot be found on object of type 'xx' - maybe not public?
- org.springframework.expression.spel.SpelEvaluationException: EL1004E: Method call: Method service() cannot be found on com.my.blog.springboot.thymeleaf.util.MethodTest type
- Property or field 'LevelName' cannot be found on null
- maven使用jstl表达式和The absolute uri: http://java.sun.com/jsp/jstl/core cannot be resolved in either web.xml or the jar files deployed with this application解决
- Property with 'retain(or strong) attribute must be of object type
- 解决spring使用动态代理类型转换失败的问题--java.lang.ClassCastException: com.sun.proxy.$Proxy$ cannot be cast to ...今天
- Property 'navigationController' not found on object of type '...'
- Property with 'retain (or strong)' attribute must be of object type
- XCode中互相包含引起的"property with 'retain(or strong)' attribute must be of object type"错误与解决
- org.springframework.expression.spel.SpelEvaluationException: EL1005E:(pos 0): Type cannot be found
- 解决must be of type [com.bysj.services.CompanyServiceImp], but was actually of type [com.sun.proxy.$Pr
- 解决spring使用动态代理类型转换失败的问题--java.lang.ClassCastException: com.sun.proxy.$Proxy$ cannot be cast to ...
- Cannot find any information on property 'User' in a bean of type 'com.entity.user'
- 解决spring使用动态代理类型转换失败的问题--java.lang.ClassCastException: com.sun.proxy.$Proxy$ cannot be cast to ...
- 解决编译错误:Property 'value' not found on object of type '_strong id'
- Property 'edgesForExtendedlayout' not found on object of type 解决方案