Feign 客户端子域:模糊映射

Feign client sub-domain : ambiguous mapping

我正在使用 Spring Boot 2.0.3.RELEASE 和 openFeign:

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
        </dependency>

我在我的项目中声明了两个假客户:

@FeignClient(name = "appleReceiptSandboxFeignClient",
    url = "https://sandbox.itunes.apple.com",
    configuration = Conf.class)
@RequestMapping(produces = "application/json", consumes = "application/json")
public interface AppleReceiptSandboxFeignClient {

    @RequestMapping(value = "/verifyReceipt", method = RequestMethod.POST)
    AppleReceiptResponseDTO sandboxVerifyReceipt(@RequestBody AppleReceiptRequestDTO dto);

}
@FeignClient(name = "appleReceiptFeignClient",
    url = "https://buy.itunes.apple.com")
@RequestMapping(produces = "application/json", consumes = "application/json")
public interface AppleReceiptFeignClient {

    @RequestMapping(value = "/verifyReceipt", method = RequestMethod.POST)
    AppleReceiptResponseDTO productionVerifyReceipt(@RequestBody AppleReceiptRequestDTO dto);

}

我的问题是,即使基本 url 和名称不同,似乎也认为假客户端发生冲突。

java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'com.myproject.central.client.AppleReceiptSandboxFeignClient' method 
public abstract com.myproject.central.client.dto.AppleReceiptResponseDTO com.myproject.central.client.AppleReceiptSandboxFeignClient.sandboxVerifyReceipt(com.myproject.central.client.dto.AppleReceiptRequestDTO)
to {[/verifyReceipt],methods=[POST],consumes=[application/json],produces=[application/json]}: There is already 'com.myproject.central.client.AppleReceiptFeignClient' bean method
public abstract com.myproject.central.client.dto.AppleReceiptResponseDTO com.myproject.central.client.AppleReceiptFeignClient.productionVerifyReceipt(com.myproject.central.client.dto.AppleReceiptRequestDTO) mapped.

即使这个映射错误是意外的,我也乐于接受解决方法。

我显然不能在同一个假客户端中声明两个端点,因为子域不同,或者我可能遗漏了什么?

我的问题是:仅使用假客户端的最简单的解决方法(如果有的话)是什么?

当您使用 @RequestMapping 注释接口或 Class 时,即使您有 @FeignClient 注释,Spring 也会注册一个处理程序。您可以通过从界面中删除注释并仅在方法上使用它来解决此问题。

@FeignClient(name = "appleReceiptSandboxFeignClient",
        url = "https://sandbox.itunes.apple.com",
        configuration = Conf.class)
public interface AppleReceiptSandboxFeignClient {

    @RequestMapping(value = "/verifyReceipt", method = RequestMethod.POST, produces = "application/json", consumes = "application/json", pro)
    AppleReceiptResponseDTO sandboxVerifyReceipt(@RequestBody AppleReceiptRequestDTO dto);

}
@FeignClient(name = "appleReceiptFeignClient",
        url = "https://buy.itunes.apple.com")
public interface AppleReceiptFeignClient {

    @RequestMapping(value = "/verifyReceipt", method = RequestMethod.POST, produces = "application/json", consumes = "application/json")
    AppleReceiptResponseDTO productionVerifyReceipt(@RequestBody AppleReceiptRequestDTO dto);

}