FeignClient in spring boot 2

僤鯓⒐⒋嵵緔 提交于 2019-12-04 19:34:52

问题


I am trying to migrate from spring boot 1.5 tio 2.0 and faced problem: I changed version of spring-cloud-netflix-core from 1.3.4.RELEASE to 2.0.1.RELEASE:

    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-netflix-core</artifactId>
        <version>2.0.1.RELEASE</version>
    </dependency>

Unfortunately, feign library imports failed:

import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.cloud.netflix.feign.FeignAutoConfiguration;
import org.springframework.cloud.netflix.feign.FeignClient;

There is no library .feign in new 2.0.1 version. What should I use instead? (connot leave old cloud version because of conflict with spring boot autoconfiguration)


回答1:


Since the 2.x release Spring Cloud moved the netflix feign classes to their own project.

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

You need to update your re-import with the correct package

org.springframework.cloud.openfeign




回答2:


You need to import feign as an independent dependency starting from 2.X release:

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


来源:https://stackoverflow.com/questions/52365074/feignclient-in-spring-boot-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!