概述
注入services对象时,一直报下面的错误
Caused by: java.lang.RuntimeException: to set field[asuraStrategyService] value into target[com.alibaba.intl.asura.services.impl.AsuraStrategyServiceImplTest] error.
at org.jtester.bytecode.reflector.helper.FieldHelper.setFieldValue(FieldHelper.java:74)
at org.jtester.module.spring.strategy.injector.SpringBeanInjectorByName.injectBy(SpringBeanInjectorByName.java:41)
... 38 more
Caused by: java.lang.IllegalArgumentException: Can not set com.alibaba.intl.asura.services.impl.AsuraStrategyServiceImpl field com.alibaba.intl.asura.services.impl.AsuraStrategyServiceImplTest.asuraStrategyService to $Proxy14
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
at java.lang.reflect.Field.set(Field.java:657)
at org.jtester.bytecode.reflector.helper.FieldHelper.setFieldValue(FieldHelper.java:70)
... 39 more
查了很久,debug发现提示的是没有访问权限,仔细一看原来代码写成
@SpringBeanByName
AsuraStrategyServiceImpl asuraStrategyService;
这样了,实际上应该是
@SpringBeanByName
AsuraStrategyService asuraStrategyService;
错把字段asuraStrategyService申明为接口对象了,这样肯定是没有权限访问的了
最后
以上就是畅快便当为你收集整理的@SpringBeanByName 时的一个错误的全部内容,希望文章能够帮你解决@SpringBeanByName 时的一个错误所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复