简体   繁体   English

是否有可能从 MyBatis MapperProxy 获取对象?

[英]Is there possibility to get object from MyBatis MapperProxy?

I would like to spy with Mockito if MyBatis Mapper methods are invoked and how many times, but I'm not able to do this while I'm getting the我想监视 Mockito 是否调用了 MyBatis Mapper 方法以及调用了多少次,但是在获得

org.apache.ibatis.binding.MapperProxy

instead of my mapper implementation.而不是我的映射器实现。 Is there any possibility to get an object from this Proxy?是否有可能从此代理获取对象? Or is there any other solution to spy with Mockito over Mapper methods?或者有没有其他解决方案可以通过 Mockito 来监视 Mapper 方法?

MyBatis version: 3.4.1 MyBatis 版本:3.4.1

Mockito version: 1.9.5 Mockito 版本:1.9.5

Spring version: 3.2.8.RELEASE春季版本:3.2.8.RELEASE

To get object from MyBatis MapperProxy is not possible, at least I didn't found any way to obtain such an object, but it is possible to spy MyBatis Mapper using annotation @SpyBean and mockito inline:从 MyBatis MapperProxy 获取对象是不可能的,至少我没有找到任何方法来获取这样的对象,但是可以使用注释 @SpyBean 和 mockito inline 来监视 MyBatis Mapper:

<dependency>
    <groupId>org.mockito</groupId>
    <artifactId>mockito-inline</artifactId>
    <version>${mockito.version}</version>
    <scope>test</scope>
</dependency>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM