首页 > 编程语言 > 详细

springboot openfeignclient

时间:2021-03-16 17:22:19      阅读:34      评论:0      收藏:0      [点我收藏+]
因为业务需要,暂时不需要springcloud。但是内部接口之间调用比较多,所以就在springboot里面加入了openfeign的模块。
1.在pom文件中的dependencies节点加入如下代码

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

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

2.在dependencyManagement节点中加入如下代码

       <dependencies>
            <dependency>
                <groupId>org.springframework.cloud</groupId>
                <artifactId>spring-cloud-dependencies</artifactId>
                <version>${spring.cloud-version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>

3.在启动类加上 @EnableFeignClients
4.创建feign服务接口 在接口上加上

@Component
@FeignClient(name = "服务名字随便起一个就好了", url = "服务地址")

因为加入服务发现,所以feign服务接口上面接口地址就写死了

springboot openfeignclient

原文:https://blog.51cto.com/14904501/2661470

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!