Summary of all aspects of getting started with SpringCloud Alibaba components (Part 1): registration center-nacos, load balancing-ribbon, remote calling-feign

Article directory Nacos Ribbon Feign FeignExpansion Nacos Concept: Nacos is a new open source project launched by Alibaba. It is a dynamic service discovery, configuration management and service management platform that makes it easier to build cloud native applications. Nacos is committed to helping users discover, configure and manage microservices. It provides a simple and […]

Spring Cloud Alibaba OpenFeign

OpenFeig is a declarative REST client. OpenFeig generates a dynamic implementation of the interface (pseudo client) by using JAX-RS or SpringMVC annotations modification methods. OpenFeig is used by consumers to call providers, so OpenFeig only involves consumers. OpenFeign has a load balancing function, which can consume and access specified microservices in a load balancing manner. […]

Solve the problem that springboot integrates websocket, redis, openfeign, redisTemplate, and openfeign classes that cannot be injected

In some businesses, we need to use long connections. We can use http long connections or websocket. In the framework of springboot as the backend, the technologies that can be borrowed are (netty, websocket) The version is as follows Software Version number jdk 21 springboot 3.1.5 springcloud 2022.0.4 Scene recurrence pom file <?xml version=”1.0″ encoding=”UTF-8″?> […]

SpringCloudAlibaba 2021.0.1 – Complete project construction (Nacos + OpenFeign + Getway + Sentinel)

Table of Contents 1. Complete construction of SpringCloudAlibaba project 1.1. Initialization project 1.1.1. Create project 1.1.2. Configure the pom.xml of the parent project 1.1.3. Create submodules 1.2. user microservice 1.2.1. Configuration pom.xml 1.2.2. Create application.yml configuration file 1.2.3. Create startup class 1.2.4. Testing 1.3. product microservice 1.3.1. Configuration pom.xml 1.3.2. Create application.yml configuration file 1.3.3. […]

Feign core source code analysis

As a declarative HTTP service client, Feign can complete the call to the service provider interface by adding annotations to the interface, which greatly simplifies our work when calling services. 01 Initialization Phase First, take a look at Feign’s opening annotation @EnableFeignClients: @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.TYPE) @Documented @Import(FeignClientsRegistrar.class) public @interface EnableFeignClients {<!– –> String[] value() default {<!– […]

Simplify local Feign calls based on Nacos

In daily work, OpenFeign is very commonly used as a calling component between microservices. The calling method of interfaces and annotations highlights simplicity, allowing us to implement interfaces between services without paying attention to internal details. transfer. However, after using it for a long time at work, I found that Feign also has some troubles […]

If the new Feign interface is started according to the microservice, an error will be reported: org.springframework.beans.factory.UnsatisfiedDependencyException:

Startup error: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘jgEntInfoController’: Unsatisfied dependency expressed through field ‘remoteJgEntInfoService’; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘ com.supervise.system.api.RemoteJgEntInfoService’: Unexpected exception during bean creation; nested exception is java.lang.IllegalStateException: No fallbackFactory instance of type class com.supervise.system.api.factory.RemoteJgEntInfoFallbackFactory found for feign client remoteJgEntInfoService question: rg.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean named ‘jgEntInfoController’: Dependency […]

Feign: fusing, introduction to @FeignClient annotation parameters, optimization

Compared with RestTemplate, it is easier to understand and the operation is more dynamic. code show as below: @GetMapping(“/buy/{id}”) public Product order() { Product product = restTemplate.getForObject(“http://shop-serviceproduct/product/1”,Product.class); return product; } As can be seen from the code, we construct the URL by concatenating strings, and the URL has only one parameter. However, in reality, URLs […]

Feign implements global custom exception handling

Problem description: During development, when service A uses Feign to call service B, the parameter verification in service B fails and a custom exception is thrown. The error code is a custom error code. The error message is “XXXXX cannot be empty”. Return to When serving A, the feign exception interception of service A cannot […]

The use of Feign under Spring cloud multi-module development, and the solution to the exception that @FeignClient injects beans and cannot find it

1. About Feign In the development of microservice architecture, we often call other services in a project. In fact, this requirement can be achieved using Spring Cloud Ribbon. RestTemplate’s request interception is used to implement interface calls to dependent services. However, in actual projects, service dependencies There may be more than one call, and often […]