Openfeign客户端调用命名规范|学习笔记

简介: 快速学习Openfeign客户端调用命名规范

开发者学堂课程【精通Spring Cloud Alibaba:Openfeign客户端调用命名规范】学习笔记,与课程紧密联系,让用户快速学习知识。

课程地址https://developer.aliyun.com/learning/course/634/detail/10082


Openfeign客户端调用命名规范


微服务架构基本的样式最大的优点能够对我们 feign 实现复用机制。

注意 feign 客户端调用的事项:

如果请求参数没有加上注解的话,默认采用 post 请求发送

Openfeign,默认是支持负载均衡, ribbon。

Nacos 服务注册服务名称是否有下划线。

在微服务架构中服务的名称命名不能够有下划线。

Rest、openfeign 都学习.

SpringGloud.与SpringGloudalibaba有区别。

代码如下:

@FeignClient("meitemayikt-member")

public interface MemberServiceFeign {

**

*提供我们发布的接口

@param userId

@return

@GetMapping("/getuser")

String getUser(@RequestParam("userId") Integer userId);

Ispring:

application:

###服务的名称

name: meitemayikt-member

cloud:

nacos:

discovery:

###nacos注册地址

server-addr: 127.0.0.1:8848

server:

port:8081

2020-01-09 22:01:57.546 INFO 1729704 ---[

main] ConfigServletWebServerApplicationContext:

Refreshing org.springframework.boot.web.servlet.context

.AnnotationConfigServletWebServerApplicationContext@9573584: startup date [Thu Jan 09 22:01:57 CST

2020]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@3e92efc3

2020-01-09 22:01:57.719 ERROR 1729704 ---[

main] o.s.boot.SpringApplication  

Application run failed  

java.lang.IllegalStateException: Service id not legal hostname (meitemayikt_member)

at org.springframework.util.Assert.state(Assert.java:73)~[spring-core-5.0.4.RELEASE.jar:5.0.4

.RELEASE]

at org.springframework.cloud.openfeign.FeignClientsRegistrar.getName(FeignCl[entsRegistrar.java:237)

S~[spring-cloud-openfeign-core-2.0.0.RELEASE.jar:2.0.0.RELEASE]

at org.springframework.cloud.openfeign.FeignClientsRegistrar.registerFeignClient

(FeignClientsRegistrar.java:172)~[spring-cloud-openfeign-core-2.0.0.RELEASE.jar:2.0.0.RELEASE]

at org.springframework.cloud.openfeign.FeignClientsRegistrar.registerFeignclients

(FeignClientsRegistrar.java:158)~[spring-cloud-openfeign-core-2.0.0.RELEASE.jar:2.0.0.REL可】

at org.springframework.cloud.openfeign.FeignClientsRegistrar.registerBeanDefinitions

(FeignClientsRegistrar.java:83)~[spring-cloud-openfeign-core-2.0.0.RELEASE.jar:2.0.0.RELEASE]

at org.springframework.context.annotation.ConfigurationClassBeanDefinitionReader

!annotation.getClass(attributeName:"fallback").isInterface(),

message:"Fallback class must implement the interface annotated by @Fe

D

Assert.isTrue(

!annotation.getClass(attributeName:"fallbackFactory").isInterface(),

message:"Fallback factory must produce instances of fallback classes

/* for testing */ String getName(Map attributes){

String name =(String) attributes.get("serviceld");

if (!StringUtils.hasText(name)){

name =(String) attributes.get("name");

if (!StringUtils.hasText(name)){

name =(String) attributes.get("value");

相关文章
|
消息中间件 NoSQL Cloud Native
对Confluent一些解读
对Kafka母公司Confluent IPO、产品、技术一些看法
4888 0
对Confluent一些解读
|
缓存 NoSQL Java
【JetCache】JetCache的使用方法与步骤
【JetCache】JetCache的使用方法与步骤
6602 0
|
缓存 JSON 前端开发
CORS 详解,终于不用担心跨域问题了
CORS 详解,终于不用担心跨域问题了
8192 1
CORS 详解,终于不用担心跨域问题了
|
消息中间件 Java 物联网
一文搞懂MQTT,如何在SpringBoot中使用MQTT实现消息的订阅和发布
之前介绍了RabbitMQ以及如何在SpringBoot项目中整合使用RabbitMQ,看过的朋友都说写的比较详细,希望再总结一下目前比较流行的MQTT。所以接下来,就来介绍什么MQTT?它在IoT中有着怎样的作用?如何在项目中使用MQTT?
18663 63
一文搞懂MQTT,如何在SpringBoot中使用MQTT实现消息的订阅和发布
|
6月前
|
前端开发 JavaScript 应用服务中间件
前端跨域问题解决Access to XMLHttpRequest at xxx from has been blocked by CORS policy
跨域问题是前端开发中常见且棘手的问题,但通过理解CORS的工作原理并应用合适的解决方案,如服务器设置CORS头、使用JSONP、代理服务器、Nginx配置和浏览器插件,可以有效地解决这些问题。选择合适的方法可以确保应用的安全性和稳定性,并提升用户体验。
3783 90
|
缓存 NoSQL Java
Spring Boot 3 整合 Spring Cache 与 Redis 缓存实战
Spring Boot 3 整合 Spring Cache 与 Redis 缓存实战
|
JSON 负载均衡 Java
SpringCloud Feign 远程调用(史上最详细讲解)
SpringCloud Feign 远程调用(史上最详细讲解)
13591 0
SpringCloud Feign 远程调用(史上最详细讲解)
|
缓存 监控 安全
Spring AOP 详细深入讲解+代码示例
Spring AOP(Aspect-Oriented Programming)是Spring框架提供的一种面向切面编程的技术。它通过将横切关注点(例如日志记录、事务管理、安全性检查等)从主业务逻辑代码中分离出来,以模块化的方式实现对这些关注点的管理和重用。 在Spring AOP中,切面(Aspect)是一个模块化的关注点,它可以跨越多个对象,例如日志记录、事务管理等。切面通过定义切点(Pointcut)和增强(Advice)来介入目标对象的方法执行过程。 切点是一个表达式,用于匹配目标对象的一组方法,在这些方法执行时切面会被触发。增强则定义了切面在目标对象方法执行前、执行后或抛出异常时所
16038 4
|
11月前
|
Linux Docker 容器
Centos安装docker(linux安装docker)——超详细小白可操作手把手教程,包好用!!!
本篇博客重在讲解Centos安装docker,经博主多次在不同服务器上测试,极其的稳定,尤其是阿里的服务器,一路复制命令畅通无阻。
17891 5
Centos安装docker(linux安装docker)——超详细小白可操作手把手教程,包好用!!!
|
Kubernetes 应用服务中间件 nginx
史上最全干货!Kubernetes 原理+实战总结(全文6万字,90张图,100个知识点)(上)
史上最全干货!Kubernetes 原理+实战总结(全文6万字,90张图,100个知识点)
50914 30

热门文章

最新文章