SpringBoot-Feign快速搭建
2020-06-04 08:15
56 查看
SpringBoot-Feign快速搭建
- 添加依赖
<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-openfeign</artifactId> </dependency>
- 加注解
import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.client.discovery.EnableDiscoveryClient; import org.springframework.cloud.openfeign.EnableFeignClients; @SpringBootApplication @EnableDiscoveryClient @EnableFeignClients(basePackages = "com.eden")// 扫描Feign接口所长位置 public class ConsumerFeign01Application { public static void main(String[] args) { SpringApplication.run(ConsumerFeign01Application.class, args); } }
- 测试
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.RequestMapping; /** * @author Eden * @date 2020/5/1 16:54 */ @FeignClient(name = "provider-ribbon")// 需要调用的服务名 public interface DemoFeign { @RequestMapping(value = "/user") public String test(); }
demo代码
主要是如下几个模块不要在意provider-ribbon-xx的名字没特殊含义只是一个provider节点
相关文章推荐
- springboot (1) 快速搭建简单项目
- 数据库使用方法+SpringBoot+Mybatis快速搭建+导入tomcat+访问服务器数据库
- Spring Boot+JPA+Mysql+ThymeLeaf快速构建CURD系统(二)搭建SpringBoot工程
- Spring Boot+JPA+Mysql+ThymeLeaf快速构建CURD系统(二)搭建SpringBoot工程
- Spring Boot基础:Spring Boot简介与快速搭建(1)
- 004-Spring boot 快速入门-项目搭建与启动、SpringBootApplication
- 2分钟快速搭建Spring Boot 开发环境搭建和项目启动
- 使用maven 快速搭建springboot项目
- Spring-Boot快速搭建web项目详细总结
- 快速搭建第一个简单的SpringBoot项目
- SpringBoot 快速搭建
- 【SpringBoot】快速搭建SpringBoot+Maven+MyBatis注解
- 一步步学习SpringBoot(一) 快速搭建一个web
- Spring-boot:快速搭建微框架服务
- springboot快速搭建ssm项目
- SpringBoot快速搭建web项目详细步骤总结
- Spring Boot-RESTfull API简单项目的快速搭建
- Spring Boot+JPA+Mysql+ThymeLeaf快速构建CURD系统(二)搭建SpringBoot工程
- Spring Boot+JPA+Mysql+ThymeLeaf快速构建CURD系统(二)搭建SpringBoot工程
- Eclipse+Maven+Spring-boot快速搭建