模拟FeignClient不会替换Spring Boot 2.3.3中的应用程序FeignClient

问题描述

从Spring Boot 2.2.2升级到2.3.3后,不替换测试中的伪客户端。 模仿的bean似乎已实例化,但是它不能代替应用程序提供的实际FeignClient。

spring-cloud-starter-openfeign版本:2.2.5.RELEASE

spring boot版本:2.3.3.RELEASE

春季版:5.2.8。发布

我发现与这句话相关的问题已经解决,但对我来说似乎并不能代替实际的FeignClient。 https://github.com/spring-cloud/spring-cloud-openfeign/issues/336

https://github.com/spring-cloud/spring-cloud-openfeign/issues/337

@SpringBoottest(classes = [SomeApplication.class],webEnvironment = SpringBoottest.WebEnvironment.RANDOM_PORT)
@ContextConfiguration(classes = [ApplicationTestConfig])
@ActiveProfiles("test")
@TestExecutionListeners([DependencyInjectionTestExecutionListener,TransactionalTestExecutionListener])
@AutoConfiguremockmvc
abstract class AbstractControllerSpecification extends AbstractSpecification {}

对于ApplicationTestConfig我有类似的东西

@EntityScan(basePackages = "somepackage")
@ComponentScan(basePackages = "somepackage")
@IntegrationComponentScan(basePackages = "somepackage")
@Profile("test")
class ApplicationTestConfig {

    DetachedMockFactory factory = new DetachedMockFactory()

    @Bean
    SomeResource someResource() {
        factory.Mock(someResource)
    }
}

我发现一种解决方法是设置FeignClient(primary = false),它似乎工作正常,但我认为这不是解决方案。

任何想法在2.3.3中是否仍然存在问题?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)