如何从另一个库的Feign界面获取Feign Client

时间:2019-01-31 15:17:41

标签: spring spring-boot spring-cloud-feign feign

我有一个spring应用,我需要从REST API中获取一些数据,为此我有一个使用Feign的第三方库。它确实提供了具有Feign批注的接口,但我无法获得工作对象。 我添加到pom spring-cloud-starter-openfeign

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

这是我图书馆的代码

public interface MyFeignRepository {

@RequestLine("GET /my_repo/geodatamatcher/extractGeoCities/{application}/{country}/{environment}?string={query}")
String extractGeoCities(@Param("application") String application,
                        @Param("country") String country,
                        @Param("environment") String environment,
                        @Param("query") String query);
}

我试图做这样的事情,但我收到了java.lang.AbstractMethodError: null如何获得假冒的客户吗?

@Import(FeignClientsConfiguration.class)
class MyFeignRepositoryFeignClient {

private MyFeignRepository myFeignRepository;

@Autowired
MyFeignRepositoryFeignClient(final Decoder decoder, final Encoder encoder, final Client client, final Contract contract) {
    this.myFeignRepository = Feign.builder().client(client)
            .encoder(encoder)
            .decoder(decoder)
            .contract(contract)
            .target(MyFeignRepository.class, "http://example.com");
}
}

我尝试运行此应用程序时的堆栈跟踪

java.lang.AbstractMethodError: null
    at org.springframework.core.OrderComparator.findOrder(OrderComparator.java:142) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.core.annotation.AnnotationAwareOrderComparator.findOrder(AnnotationAwareOrderComparator.java:65) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:125) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.core.OrderComparator.getOrder(OrderComparator.java:113) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.core.OrderComparator.doCompare(OrderComparator.java:82) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at org.springframework.core.OrderComparator.compare(OrderComparator.java:68) ~[spring-core-5.0.9.RELEASE.jar:5.0.9.RELEASE]
    at java.util.TimSort.countRunAndMakeAscending(TimSort.java:360) ~[na:1.8.0_171]
    at java.util.TimSort.sort(TimSort.java:220) ~[na:1.8.0_171]
    at java.util.Arrays.sort(Arrays.java:1512) ~[na:1.8.0_171]
    at java.util.ArrayList.sort(ArrayList.java:1462) ~[na:1.8.0_171]
    at org.springframework.boot.SpringApplication.asUnmodifiableOrderedSet(SpringApplication.java:1344) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.SpringApplication.getListeners(SpringApplication.java:1253) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.context.event.EventPublishingRunListener.contextLoaded(EventPublishingRunListener.java:85) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.SpringApplicationRunListeners.contextLoaded(SpringApplicationRunListeners.java:66) ~[spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.SpringApplication.prepareContext(SpringApplication.java:408) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:331) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1277) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:1265) [spring-boot-2.0.5.RELEASE.jar:2.0.5.RELEASE]

0 个答案:

没有答案