org.mockito.exceptions.base.MockitoException:
Cannot instantiate @InjectMocks field named ‘productLogic’ of type ‘class .ProductLogic’.
You haven’t provided the instance at field declaration so I tried to construct the instance.
However the constructor or the initialization block threw an exception : GC overhead limit exceeded
Caused by: java.lang.OutOfMemoryError: GC overhead limit exceeded
我在编译的时候运行了所有的单元测试,结果就报了这个错,
但是单独运行这个单元测试是没问题的。
在运行测试的时候,可以在idea里边运行jconsole查看一下具体的堆内存,能看到堆内存确实被打满了。。
尝试了一下解决方案:
1.修改IDEA的运行内存,调大到了8192M
修改完重启仍然有这个错误,用了第二种方法
怀疑是我的IDEA窗口开了太多,关了其他窗口只留了当前项目,结果就可以了。。。
另外也可以检查一下stash的区域是不是有较大的变动,有可能也和这个有关。
我试了以上方法后还是有这个问题,改了编译内存也不行,后来把一些test(非mock的单元测试)不运行,好像就没这个问题了。。。
其他情况调整一下maven的编译内存,建议参考
:参考1
参考2
参考3
参考4