本文主要是介绍SpringBootTest测试框架三,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
feign调用mock
注入feign调用的拦截器,自定义InvocationHandlerFactory,重写代理类的实现。
@Beanpublic Feign.Builder feignBuilder() {return Feign.builder().invocationHandlerFactory((target, dispatch) -> new FeignResultInvocationHandler(target, dispatch));}
public class FeignResultInvocationHandler implements InvocationHandler {public static final Logger logger = LoggerFactory.getLogger(FeignResultInvocationHandler.class);private final Target target;private final Map<Method, InvocationHandlerFactory.MethodHandler> dispatch;public FeignResultInvocationHandler(Target target, Map<Method, InvocationHandlerFactory.MethodHandler> dispatch) {this.target = checkNotNull(target, "target"
这篇关于SpringBootTest测试框架三的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!