but was actually of type [com.sun.proxy.$Proxy191]
今天想用Junit Test一个东西,然后报错:is expected to be of type ‘****‘ but was actually of type ‘com.sun.proxy.$Proxy**
首先,我是搜了以后看到这篇文章:https://blog.csdn.net/xiaoshuo566/article/details/84636263
里面提到:
testA类继承了BaseTest,但是如果你在自动注入到了类上,如下:
@Aotuware
TestA testA;
就可能出现上述问题! 可以修改为
@Aotuware
BaseTest testA;
但是我的 TestA的写法是: TestA extends BaseServiceImpl implements ITestA
显然上边说让我注入BaseServiceImpl是不正确的,我发现实际这样的情况应该注入接口才对,即
@Resource
private ITestA testA;
也许这是一个很简单的地方,被我搞复杂了。
还没有评论,来说两句吧...