Spring在接口中找到多个非覆盖的抽象方法

时间:2019-03-18 17:04:29

标签: java spring microservices feign

在尝试了解如何处理伪客户端时,我遇到了一些困难,该客户端扩展了具有多个方法(端点)的接口。这是我的一个微服务的RestController:

@RestController
@RequestMapping("/api")
public interface ISPnetController {

    @GetMapping("/spnetQuery/summaryInfo/{hostname}")
    @ApiOperation(value="", nickname = "summaryInfo")
    @ResponseStatus(HttpStatus.OK)
    SPSummaryResponseDTO getSPnetSummaryData(@PathVariable("hostname") String hostname);

    @PostMapping("/spnetQuery/historyInfo")
    @ApiOperation(value="", nickname = "historyInfo")
    @ResponseStatus(HttpStatus.OK)
    SPHistoryResponseDTO getSPnetHistoryData(@RequestBody SPHistoryReqParams params);
}

现在,在我的主要服务中,我创建了一个假客户端,该客户端扩展了先前服务的控制器:

@FeignClient(name = "SPNETService")
public interface ISPnetServiceClient extends ISPnetController {
}

现在我需要实现以下bean,但是我不确定如何实现:

@Configuration
@Development
public class AppDevConf {


    @Bean
    ISPnetServiceClient spnetServiceClient()
    {
        SPSummaryResponseDTO response = new SPSummaryResponseDTO();
        response.setSpnetRecordsList(ImmutableList.of(
            new SPSummaryInfoDTO("da1", "so1", "se1", "m1", "ec1", "du1","dw","ds"),
            new SPSummaryInfoDTO("da2", "so2", "se2", "m2", "ec2", "du2","s","ds")
        ));

        SPHistoryResponseDTO historyResponse = new SPHistoryResponseDTO();
        historyResponse.setSpnetHistoryRecordsList(ImmutableList.of(
            new SPHistoryDTO("da1", "so1", "se1", "m1", "ec1", "s",2),
            new SPHistoryDTO("da2", "so2", "se2", "m2", "ec2", "du2",2)
        ));

        return hostname -> response;
        return params -> historyReponse; //Of course I can't use return twice, but this is just to demonstrate what I would want to do, and I can't figure it out how to make it work.

    }
  }

它抱怨:"Spring multiple non overriding abstract methods found in interface ISPnetServiceClient"

0 个答案:

没有答案