OpenFeign和feign使用简介

1.OpenFeign简介

Feign是一个声明式的Web Service客户端。它的出现使开发Web Service客户端变得很简单。使用Feign只需要创建一个接口加上对应的注解,比如:FeignClient注解。Feign有可插拔的注解,包括Feign注解和JAX-RS注解。
Feign也支持编码器和解码器,Spring Cloud Open Feign对Feign进行增强支持Spring MVC注解,可以像Spring Web一样使用HttpMessageConverters等。
Feign是一种声明式、模板化的HTTP客户端。在Spring Cloud中使用Feign,可以做到使用HTTP请求访问远程服务,就像调用本地方法一样的,开发者完全感知不到这是在调用远程方法,更感知不到在访问HTTP请求。

2.OpenFeign的功能

1.可插拔的注解支持,包括Feign注解和JAX-RS注解。
2.支持可插拔的HTTP编码器和解码器(Gson,Jackson,Sax,JAXB,JAX-RS,SOAP)。
3.支持Hystrix和它的Fallback。
4.支持Ribbon的负载均衡。
5.支持HTTP请求和响应的压缩。
6.灵活的配置:基于 name 粒度进行配置
7.支持多种客户端:JDK URLConnection、apache httpclient、okhttp,ribbon)
8.支持日志
9.支持错误重试
10.url支持占位符
11.可以不依赖注册中心独立运行

3.POM.xml文件

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>2.3.0.RELEASE</version><relativePath/> <!-- lookup parent from repository --></parent><groupId>com.zhangsan</groupId><artifactId>member-service-openfeign</artifactId><version>0.0.1-SNAPSHOT</version><name>member-service-openfeign</name><description>Demo project for Spring Boot</description><properties><java.version>1.8</java.version><spring-cloud.version>Hoxton.SR4</spring-cloud.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-netflix-eureka-client</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope><exclusions><exclusion><groupId>org.junit.vintage</groupId><artifactId>junit-vintage-engine</artifactId></exclusion></exclusions></dependency></dependencies><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></dependencyManagement><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project>

4.application.yml文件配置

spring:application:name: member-service-openfeigneureka:client:service-url:defaultZone:http://localhost:8761/eureka/server:port: 7777
logging:level:ROOT: INFO#针对指定的类 设置输出级别com.zhangsan.memberserviceopenfeign.client.*: debug
feign:client:config:default:loggerLevel: FULL#针对某个级别设置输出级别(设置局部的优先级别是最高的)Book-service:loggerLevel: FULL

5.Java代码块编写

BookService接口编写

package com.zhangsan.memberserviceopenfeign.client;import com.zhangsan.memberserviceopenfeign.entity.Book;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;/*** @ClassName BookService* @Description TODO* @Author ZhangSan_Plus* @Date 2020/5/18 16:41* @Version 1.0**///此处编写需要通信的微服务名称
@FeignClient(name = "Book-service")
//http://Book-service/find?sn=xx
//客户端接口 完成接口和微服务的对应
public interface BookService {//当前GetMapping是获取另一个微服务的具体控制器@GetMapping("/find")Book findBySn(@RequestParam("sn") String sn);
}

MemberServiceController控制器编写

package com.zhangsan.memberserviceopenfeign.controller;import com.zhangsan.memberserviceopenfeign.client.BookService;
import com.zhangsan.memberserviceopenfeign.entity.Book;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;import javax.annotation.Resource;/*** @ClassName MemberController* @Description TODO* @Author ZhangSan_Plus* @Date 2020/5/18 16:51* @Version 1.0**/
@Controller
public class MemberController {//把bookService注入到容器中去@ResourceBookService bookService;@GetMapping("/getBook")@ResponseBodypublic String getBook(String sn){Book bySn = bookService.findBySn(sn);return bySn.getBookName()+bySn.getDesc()+bySn.getSn()+"图书借阅成功";}
}

MemberServiceOpenfeignApplication启动类编写

package com.zhangsan.memberserviceopenfeign;import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.openfeign.EnableFeignClients;@SpringBootApplication
@EnableEurekaClient
//一定不要忘记添加这个注解
@EnableFeignClients
public class MemberServiceOpenfeignApplication {public static void main(String[] args) {SpringApplication.run(MemberServiceOpenfeignApplication.class, args);}}

效果图
在这里插入图片描述

6.OpenFeign工作原理

在这里插入图片描述

7.OpenFeign通信日志

· 基于SpringBoot的logback输出,默认debug级别
· 设置项:feign.client.config.微服务id.loggerLevel
· 微服务id:default代表全局默认配置

通信日志输出格式:

1. NONE:不输出任何通信日志
2. BASIC:只包含URL,请求方法,状态码,执行时间
3. HEADERS:在BASIC基础上额外包含请求和响应头
4. FULL:包含请求与相应内容最完整的信息
注意:针对某个微服务设置了通信日志输出级别(那么该输出级别就为最高级别也是最终级别)
在日常开发中可以使用FULL 一般推荐使用BASIC/HEADERS

application.yml配置OpenFegin通信日志

spring:application:name: member-service-openfeigneureka:client:service-url:defaultZone:http://localhost:8761/eureka/server:port: 7777
logging:level:ROOT: INFO#针对指定的类 设置输出级别com.zhangsan.memberserviceopenfeign.client.*: debug
feign:client:config:default:loggerLevel: FULL#针对某个级别设置输出级别(设置局部的优先级别是最高的)Book-service:loggerLevel: FULL

控制台输出

"C:\Program Files\Java\jdk1.8.0_51\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:D:\IDEA\IntelliJ IDEA 2018.3.5\lib\idea_rt.jar=53064:D:\IDEA\IntelliJ IDEA 2018.3.5\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_51\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_51\jre\lib\rt.jar;E:\IDEA_DESTBOK\member-service-openfeign\target\classes;C:\Users\One\.m2\repository\org\springframework\boot\spring-boot-starter-web\2.3.0.RELEASE\spring-boot-starter-web-2.3.0.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\boot\spring-boot-starter\2.3.0.RELEASE\spring-boot-starter-2.3.0.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\boot\spring-boot\2.3.0.RELEASE\spring-boot-2.3.0.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\2.3.0.RELEASE\spring-boot-autoconfigure-2.3.0.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\boot\spring-boot-starter-logging\2.3.0.RELEASE\spring-boot-starter-logging-2.3.0.RELEASE.jar;C:\Users\One\.m2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;C:\Users\One\.m2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;C:\Users\One\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.13.2\log4j-to-slf4j-2.13.2.jar;C:\Users\One\.m2\repository\org\apache\logging\log4j\log4j-api\2.13.2\log4j-api-2.13.2.jar;C:\Users\One\.m2\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;C:\Users\One\.m2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;C:\Users\One\.m2\repository\org\yaml\snakeyaml\1.26\snakeyaml-1.26.jar;C:\Users\One\.m2\repository\org\springframework\boot\spring-boot-starter-json\2.3.0.RELEASE\spring-boot-starter-json-2.3.0.RELEASE.jar;C:\Users\One\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.11.0\jackson-databind-2.11.0.jar;C:\Users\One\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.0\jackson-datatype-jdk8-2.11.0.jar;C:\Users\One\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.0\jackson-datatype-jsr310-2.11.0.jar;C:\Users\One\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.0\jackson-module-parameter-names-2.11.0.jar;C:\Users\One\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.3.0.RELEASE\spring-boot-starter-tomcat-2.3.0.RELEASE.jar;C:\Users\One\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.35\tomcat-embed-core-9.0.35.jar;C:\Users\One\.m2\repository\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;C:\Users\One\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.35\tomcat-embed-websocket-9.0.35.jar;C:\Users\One\.m2\repository\org\springframework\spring-web\5.2.6.RELEASE\spring-web-5.2.6.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\spring-beans\5.2.6.RELEASE\spring-beans-5.2.6.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\spring-webmvc\5.2.6.RELEASE\spring-webmvc-5.2.6.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\spring-aop\5.2.6.RELEASE\spring-aop-5.2.6.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\spring-context\5.2.6.RELEASE\spring-context-5.2.6.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\spring-expression\5.2.6.RELEASE\spring-expression-5.2.6.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-starter-netflix-eureka-client\2.2.2.RELEASE\spring-cloud-starter-netflix-eureka-client-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-starter\2.2.2.RELEASE\spring-cloud-starter-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-context\2.2.2.RELEASE\spring-cloud-context-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\security\spring-security-rsa\1.0.9.RELEASE\spring-security-rsa-1.0.9.RELEASE.jar;C:\Users\One\.m2\repository\org\bouncycastle\bcpkix-jdk15on\1.64\bcpkix-jdk15on-1.64.jar;C:\Users\One\.m2\repository\org\bouncycastle\bcprov-jdk15on\1.64\bcprov-jdk15on-1.64.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-netflix-hystrix\2.2.2.RELEASE\spring-cloud-netflix-hystrix-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\boot\spring-boot-starter-aop\2.3.0.RELEASE\spring-boot-starter-aop-2.3.0.RELEASE.jar;C:\Users\One\.m2\repository\org\aspectj\aspectjweaver\1.9.5\aspectjweaver-1.9.5.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-netflix-eureka-client\2.2.2.RELEASE\spring-cloud-netflix-eureka-client-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\com\netflix\eureka\eureka-client\1.9.17\eureka-client-1.9.17.jar;C:\Users\One\.m2\repository\org\codehaus\jettison\jettison\1.3.7\jettison-1.3.7.jar;C:\Users\One\.m2\repository\stax\stax-api\1.0.1\stax-api-1.0.1.jar;C:\Users\One\.m2\repository\com\netflix\netflix-commons\netflix-eventbus\0.3.0\netflix-eventbus-0.3.0.jar;C:\Users\One\.m2\repository\com\netflix\netflix-commons\netflix-infix\0.3.0\netflix-infix-0.3.0.jar;C:\Users\One\.m2\repository\commons-jxpath\commons-jxpath\1.3\commons-jxpath-1.3.jar;C:\Users\One\.m2\repository\joda-time\joda-time\2.3\joda-time-2.3.jar;C:\Users\One\.m2\repository\org\antlr\antlr-runtime\3.4\antlr-runtime-3.4.jar;C:\Users\One\.m2\repository\org\antlr\stringtemplate\3.2.1\stringtemplate-3.2.1.jar;C:\Users\One\.m2\repository\antlr\antlr\2.7.7\antlr-2.7.7.jar;C:\Users\One\.m2\repository\com\google\code\gson\gson\2.8.6\gson-2.8.6.jar;C:\Users\One\.m2\repository\org\apache\commons\commons-math\2.2\commons-math-2.2.jar;C:\Users\One\.m2\repository\com\netflix\archaius\archaius-core\0.7.6\archaius-core-0.7.6.jar;C:\Users\One\.m2\repository\com\google\guava\guava\28.2-android\guava-28.2-android.jar;C:\Users\One\.m2\repository\com\google\guava\failureaccess\1.0.1\failureaccess-1.0.1.jar;C:\Users\One\.m2\repository\com\google\guava\listenablefuture\9999.0-empty-to-avoid-conflict-with-guava\listenablefuture-9999.0-empty-to-avoid-conflict-with-guava.jar;C:\Users\One\.m2\repository\org\checkerframework\checker-compat-qual\2.5.5\checker-compat-qual-2.5.5.jar;C:\Users\One\.m2\repository\com\google\errorprone\error_prone_annotations\2.3.4\error_prone_annotations-2.3.4.jar;C:\Users\One\.m2\repository\com\google\j2objc\j2objc-annotations\1.3\j2objc-annotations-1.3.jar;C:\Users\One\.m2\repository\javax\ws\rs\jsr311-api\1.1.1\jsr311-api-1.1.1.jar;C:\Users\One\.m2\repository\com\netflix\servo\servo-core\0.12.21\servo-core-0.12.21.jar;C:\Users\One\.m2\repository\com\sun\jersey\jersey-core\1.19.1\jersey-core-1.19.1.jar;C:\Users\One\.m2\repository\com\sun\jersey\jersey-client\1.19.1\jersey-client-1.19.1.jar;C:\Users\One\.m2\repository\com\sun\jersey\contribs\jersey-apache-client4\1.19.1\jersey-apache-client4-1.19.1.jar;C:\Users\One\.m2\repository\org\apache\httpcomponents\httpclient\4.5.12\httpclient-4.5.12.jar;C:\Users\One\.m2\repository\org\apache\httpcomponents\httpcore\4.4.13\httpcore-4.4.13.jar;C:\Users\One\.m2\repository\commons-codec\commons-codec\1.14\commons-codec-1.14.jar;C:\Users\One\.m2\repository\com\google\inject\guice\4.1.0\guice-4.1.0.jar;C:\Users\One\.m2\repository\javax\inject\javax.inject\1\javax.inject-1.jar;C:\Users\One\.m2\repository\aopalliance\aopalliance\1.0\aopalliance-1.0.jar;C:\Users\One\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.11.0\jackson-annotations-2.11.0.jar;C:\Users\One\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.11.0\jackson-core-2.11.0.jar;C:\Users\One\.m2\repository\com\netflix\eureka\eureka-core\1.9.17\eureka-core-1.9.17.jar;C:\Users\One\.m2\repository\com\fasterxml\woodstox\woodstox-core\5.2.1\woodstox-core-5.2.1.jar;C:\Users\One\.m2\repository\org\codehaus\woodstox\stax2-api\4.2\stax2-api-4.2.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-starter-netflix-archaius\2.2.2.RELEASE\spring-cloud-starter-netflix-archaius-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-netflix-ribbon\2.2.2.RELEASE\spring-cloud-netflix-ribbon-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-netflix-archaius\2.2.2.RELEASE\spring-cloud-netflix-archaius-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\commons-configuration\commons-configuration\1.8\commons-configuration-1.8.jar;C:\Users\One\.m2\repository\commons-lang\commons-lang\2.6\commons-lang-2.6.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-starter-netflix-ribbon\2.2.2.RELEASE\spring-cloud-starter-netflix-ribbon-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\com\netflix\ribbon\ribbon\2.3.0\ribbon-2.3.0.jar;C:\Users\One\.m2\repository\com\netflix\ribbon\ribbon-transport\2.3.0\ribbon-transport-2.3.0.jar;C:\Users\One\.m2\repository\io\reactivex\rxnetty-contexts\0.4.9\rxnetty-contexts-0.4.9.jar;C:\Users\One\.m2\repository\io\reactivex\rxnetty-servo\0.4.9\rxnetty-servo-0.4.9.jar;C:\Users\One\.m2\repository\io\reactivex\rxnetty\0.4.9\rxnetty-0.4.9.jar;C:\Users\One\.m2\repository\com\netflix\ribbon\ribbon-core\2.3.0\ribbon-core-2.3.0.jar;C:\Users\One\.m2\repository\com\netflix\ribbon\ribbon-httpclient\2.3.0\ribbon-httpclient-2.3.0.jar;C:\Users\One\.m2\repository\commons-collections\commons-collections\3.2.2\commons-collections-3.2.2.jar;C:\Users\One\.m2\repository\com\netflix\netflix-commons\netflix-commons-util\0.3.0\netflix-commons-util-0.3.0.jar;C:\Users\One\.m2\repository\com\netflix\ribbon\ribbon-loadbalancer\2.3.0\ribbon-loadbalancer-2.3.0.jar;C:\Users\One\.m2\repository\com\netflix\netflix-commons\netflix-statistics\0.1.1\netflix-statistics-0.1.1.jar;C:\Users\One\.m2\repository\io\reactivex\rxjava\1.3.8\rxjava-1.3.8.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-starter-loadbalancer\2.2.2.RELEASE\spring-cloud-starter-loadbalancer-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-loadbalancer\2.2.2.RELEASE\spring-cloud-loadbalancer-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\io\projectreactor\reactor-core\3.3.5.RELEASE\reactor-core-3.3.5.RELEASE.jar;C:\Users\One\.m2\repository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;C:\Users\One\.m2\repository\io\projectreactor\addons\reactor-extra\3.3.3.RELEASE\reactor-extra-3.3.3.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\boot\spring-boot-starter-cache\2.3.0.RELEASE\spring-boot-starter-cache-2.3.0.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\spring-context-support\5.2.6.RELEASE\spring-context-support-5.2.6.RELEASE.jar;C:\Users\One\.m2\repository\com\stoyanr\evictor\1.0.0\evictor-1.0.0.jar;C:\Users\One\.m2\repository\com\netflix\ribbon\ribbon-eureka\2.3.0\ribbon-eureka-2.3.0.jar;C:\Users\One\.m2\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;C:\Users\One\.m2\repository\com\thoughtworks\xstream\xstream\1.4.11.1\xstream-1.4.11.1.jar;C:\Users\One\.m2\repository\xmlpull\xmlpull\1.1.3.1\xmlpull-1.1.3.1.jar;C:\Users\One\.m2\repository\xpp3\xpp3_min\1.1.4c\xpp3_min-1.1.4c.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-starter-openfeign\2.2.2.RELEASE\spring-cloud-starter-openfeign-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-openfeign-core\2.2.2.RELEASE\spring-cloud-openfeign-core-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\io\github\openfeign\form\feign-form-spring\3.8.0\feign-form-spring-3.8.0.jar;C:\Users\One\.m2\repository\io\github\openfeign\form\feign-form\3.8.0\feign-form-3.8.0.jar;C:\Users\One\.m2\repository\commons-fileupload\commons-fileupload\1.4\commons-fileupload-1.4.jar;C:\Users\One\.m2\repository\commons-io\commons-io\2.2\commons-io-2.2.jar;C:\Users\One\.m2\repository\org\springframework\cloud\spring-cloud-commons\2.2.2.RELEASE\spring-cloud-commons-2.2.2.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\security\spring-security-crypto\5.3.2.RELEASE\spring-security-crypto-5.3.2.RELEASE.jar;C:\Users\One\.m2\repository\io\github\openfeign\feign-core\10.7.4\feign-core-10.7.4.jar;C:\Users\One\.m2\repository\io\github\openfeign\feign-slf4j\10.7.4\feign-slf4j-10.7.4.jar;C:\Users\One\.m2\repository\io\github\openfeign\feign-hystrix\10.7.4\feign-hystrix-10.7.4.jar;C:\Users\One\.m2\repository\com\netflix\hystrix\hystrix-core\1.5.18\hystrix-core-1.5.18.jar;C:\Users\One\.m2\repository\org\hdrhistogram\HdrHistogram\2.1.9\HdrHistogram-2.1.9.jar;C:\Users\One\.m2\repository\org\springframework\spring-core\5.2.6.RELEASE\spring-core-5.2.6.RELEASE.jar;C:\Users\One\.m2\repository\org\springframework\spring-jcl\5.2.6.RELEASE\spring-jcl-5.2.6.RELEASE.jar" com.zhangsan.memberserviceopenfeign.MemberServiceOpenfeignApplication.   ____          _            __ _ _/\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \\\/  ___)| |_)| | | | | || (_| |  ) ) ) )'  |____| .__|_| |_|_| |_\__, | / / / /=========|_|==============|___/=/_/_/_/:: Spring Boot ::        (v2.3.0.RELEASE)2020-05-19 09:44:54.746  INFO 9612 --- [           main] c.z.m.MemberServiceOpenfeignApplication  : No active profile set, falling back to default profiles: default
2020-05-19 09:44:55.571  INFO 9612 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=93882a3d-cfb8-30b8-9985-5b57a8290773
2020-05-19 09:44:55.671  INFO 9612 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'com.zhangsan.memberserviceopenfeign.client.BookService' of type [org.springframework.cloud.openfeign.FeignClientFactoryBean] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2020-05-19 09:44:55.905  INFO 9612 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 7777 (http)
2020-05-19 09:44:55.914  INFO 9612 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2020-05-19 09:44:55.914  INFO 9612 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.35]
2020-05-19 09:44:56.089  INFO 9612 --- [           main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2020-05-19 09:44:56.090  INFO 9612 --- [           main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1322 ms
2020-05-19 09:44:56.343  WARN 9612 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2020-05-19 09:44:56.343  INFO 9612 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2020-05-19 09:44:56.347  WARN 9612 --- [           main] c.n.c.sources.URLConfigurationSource     : No URLs will be polled as dynamic configuration sources.
2020-05-19 09:44:56.347  INFO 9612 --- [           main] c.n.c.sources.URLConfigurationSource     : To enable URLs as dynamic configuration sources, define System property archaius.configurationSource.additionalUrls or make config.properties available on classpath.
2020-05-19 09:44:56.460  INFO 9612 --- [           main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
2020-05-19 09:44:59.920  WARN 9612 --- [           main] ockingLoadBalancerClientRibbonWarnLogger : You already have RibbonLoadBalancerClient on your classpath. It will be used by default. As Spring Cloud Ribbon is in maintenance mode. We recommend switching to BlockingLoadBalancerClient instead. In order to use it, set the value of `spring.cloud.loadbalancer.ribbon.enabled` to `false` or remove spring-cloud-starter-netflix-ribbon from your project.
2020-05-19 09:44:59.988  INFO 9612 --- [           main] o.s.c.n.eureka.InstanceInfoFactory       : Setting initial instance status as: STARTING
2020-05-19 09:45:00.031  INFO 9612 --- [           main] com.netflix.discovery.DiscoveryClient    : Initializing Eureka in region us-east-1
2020-05-19 09:45:00.217  INFO 9612 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON encoding codec LegacyJacksonJson
2020-05-19 09:45:00.217  INFO 9612 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using JSON decoding codec LegacyJacksonJson
2020-05-19 09:45:00.454  INFO 9612 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML encoding codec XStreamXml
2020-05-19 09:45:00.454  INFO 9612 --- [           main] c.n.d.provider.DiscoveryJerseyProvider   : Using XML decoding codec XStreamXml
2020-05-19 09:45:00.665  INFO 9612 --- [           main] c.n.d.s.r.aws.ConfigClusterResolver      : Resolving eureka endpoints via configuration
2020-05-19 09:45:02.033  INFO 9612 --- [           main] com.netflix.discovery.DiscoveryClient    : Disable delta property : false
2020-05-19 09:45:02.033  INFO 9612 --- [           main] com.netflix.discovery.DiscoveryClient    : Single vip registry refresh property : null
2020-05-19 09:45:02.033  INFO 9612 --- [           main] com.netflix.discovery.DiscoveryClient    : Force full registry fetch : false
2020-05-19 09:45:02.033  INFO 9612 --- [           main] com.netflix.discovery.DiscoveryClient    : Application is null : false
2020-05-19 09:45:02.033  INFO 9612 --- [           main] com.netflix.discovery.DiscoveryClient    : Registered Applications size is zero : true
2020-05-19 09:45:02.034  INFO 9612 --- [           main] com.netflix.discovery.DiscoveryClient    : Application version is -1: true
2020-05-19 09:45:02.034  INFO 9612 --- [           main] com.netflix.discovery.DiscoveryClient    : Getting all instance registry info from the eureka server
2020-05-19 09:45:02.208  INFO 9612 --- [           main] com.netflix.discovery.DiscoveryClient    : The response status is 200
2020-05-19 09:45:02.212  INFO 9612 --- [           main] com.netflix.discovery.DiscoveryClient    : Starting heartbeat executor: renew interval is: 30
2020-05-19 09:45:02.215  INFO 9612 --- [           main] c.n.discovery.InstanceInfoReplicator     : InstanceInfoReplicator onDemand update allowed rate per min is 4
2020-05-19 09:45:02.220  INFO 9612 --- [           main] com.netflix.discovery.DiscoveryClient    : Discovery Client initialized at timestamp 1589852702219 with initial instances count: 4
2020-05-19 09:45:02.221  INFO 9612 --- [           main] o.s.c.n.e.s.EurekaServiceRegistry        : Registering application MEMBER-SERVICE-OPENFEIGN with eureka with status UP
2020-05-19 09:45:02.221  INFO 9612 --- [           main] com.netflix.discovery.DiscoveryClient    : Saw local status change event StatusChangeEvent [timestamp=1589852702221, current=UP, previous=STARTING]
2020-05-19 09:45:02.224  INFO 9612 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_MEMBER-SERVICE-OPENFEIGN/ZhangSan-Plus:member-service-openfeign:7777: registering service...
2020-05-19 09:45:02.263  INFO 9612 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 7777 (http) with context path ''
2020-05-19 09:45:02.266  INFO 9612 --- [           main] .s.c.n.e.s.EurekaAutoServiceRegistration : Updating port to 7777
2020-05-19 09:45:02.275  INFO 9612 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient    : DiscoveryClient_MEMBER-SERVICE-OPENFEIGN/ZhangSan-Plus:member-service-openfeign:7777 - registration status: 204
2020-05-19 09:45:04.087  INFO 9612 --- [           main] c.z.m.MemberServiceOpenfeignApplication  : Started MemberServiceOpenfeignApplication in 13.802 seconds (JVM running for 16.465)
2020-05-19 09:45:07.147  INFO 9612 --- [nio-7777-exec-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
2020-05-19 09:45:07.147  INFO 9612 --- [nio-7777-exec-1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
2020-05-19 09:45:07.155  INFO 9612 --- [nio-7777-exec-1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 7 ms
2020-05-19 09:45:07.200 DEBUG 9612 --- [nio-7777-exec-1] c.z.m.client.BookService                 : [BookService#findBySn] ---> GET http://Book-service/find?sn=111 HTTP/1.1
2020-05-19 09:45:07.201 DEBUG 9612 --- [nio-7777-exec-1] c.z.m.client.BookService                 : [BookService#findBySn] ---> END HTTP (0-byte body)
2020-05-19 09:45:07.414  INFO 9612 --- [nio-7777-exec-1] c.netflix.config.ChainedDynamicProperty  : Flipping property: Book-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2020-05-19 09:45:07.457  INFO 9612 --- [nio-7777-exec-1] c.n.u.concurrent.ShutdownEnabledTimer    : Shutdown hook installed for: NFLoadBalancer-PingTimer-Book-service
2020-05-19 09:45:07.458  INFO 9612 --- [nio-7777-exec-1] c.netflix.loadbalancer.BaseLoadBalancer  : Client: Book-service instantiated a LoadBalancer: DynamicServerListLoadBalancer:{NFLoadBalancer:name=Book-service,current list of Servers=[],Load balancer stats=Zone stats: {},Server stats: []}ServerList:null
2020-05-19 09:45:07.469  INFO 9612 --- [nio-7777-exec-1] c.n.l.DynamicServerListLoadBalancer      : Using serverListUpdater PollingServerListUpdater
2020-05-19 09:45:07.504  INFO 9612 --- [nio-7777-exec-1] c.netflix.config.ChainedDynamicProperty  : Flipping property: Book-service.ribbon.ActiveConnectionsLimit to use NEXT property: niws.loadbalancer.availabilityFilteringRule.activeConnectionsLimit = 2147483647
2020-05-19 09:45:07.505  INFO 9612 --- [nio-7777-exec-1] c.n.l.DynamicServerListLoadBalancer      : DynamicServerListLoadBalancer for client Book-service initialized: DynamicServerListLoadBalancer:{NFLoadBalancer:name=Book-service,current list of Servers=[ZhangSan-Plus:8888],Load balancer stats=Zone stats: {defaultzone=[Zone:defaultzone;	Instance count:1;	Active connections count: 0;	Circuit breaker tripped count: 0;	Active connections per server: 0.0;]
},Server stats: [[Server:ZhangSan-Plus:8888;	Zone:defaultZone;	Total Requests:0;	Successive connection failure:0;	Total blackout seconds:0;	Last connection made:Thu Jan 01 08:00:00 CST 1970;	First connection made: Thu Jan 01 08:00:00 CST 1970;	Active Connections:0;	total failure count in last (1000) msecs:0;	average resp time:0.0;	90 percentile resp time:0.0;	95 percentile resp time:0.0;	min resp time:0.0;	max resp time:0.0;	stddev resp time:0.0]
]}ServerList:org.springframework.cloud.netflix.ribbon.eureka.DomainExtractingServerList@1c66fbc0
2020-05-19 09:45:07.590 DEBUG 9612 --- [nio-7777-exec-1] c.z.m.client.BookService                 : [BookService#findBySn] <--- HTTP/1.1 200 (390ms)
2020-05-19 09:45:07.590 DEBUG 9612 --- [nio-7777-exec-1] c.z.m.client.BookService                 : [BookService#findBySn] connection: keep-alive
2020-05-19 09:45:07.591 DEBUG 9612 --- [nio-7777-exec-1] c.z.m.client.BookService                 : [BookService#findBySn] content-type: application/json
2020-05-19 09:45:07.591 DEBUG 9612 --- [nio-7777-exec-1] c.z.m.client.BookService                 : [BookService#findBySn] date: Tue, 19 May 2020 01:45:07 GMT
2020-05-19 09:45:07.591 DEBUG 9612 --- [nio-7777-exec-1] c.z.m.client.BookService                 : [BookService#findBySn] keep-alive: timeout=60
2020-05-19 09:45:07.591 DEBUG 9612 --- [nio-7777-exec-1] c.z.m.client.BookService                 : [BookService#findBySn] transfer-encoding: chunked
2020-05-19 09:45:07.591 DEBUG 9612 --- [nio-7777-exec-1] c.z.m.client.BookService                 : [BookService#findBySn] 
2020-05-19 09:45:07.594 DEBUG 9612 --- [nio-7777-exec-1] c.z.m.client.BookService                 : [BookService#findBySn] {"sn":"111","bookName":"图书1","desc":"weqwe"}
2020-05-19 09:45:07.595 DEBUG 9612 --- [nio-7777-exec-1] c.z.m.client.BookService                 : [BookService#findBySn] <--- END HTTP (48-byte body)

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://xiahunao.cn/news/251666.html

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

Feign详解与实例

基本介绍 Feign是一种负载均衡的HTTP客户端, 使用Feign调用API就像调用本地方法一样&#xff0c;从避免了调用目标微服务时&#xff0c;需要不断的解析/封装json 数据的繁琐。Feign集成了Ribbon。Ribboneureka是面向微服务编程&#xff0c;而Feign是面向接口编程。 Fegin是一个…

FeignClient

FeignClient的调用 注意&#xff1a; 依赖可能会出现冲突&#xff0c;请根据spring-cloud版本选择并修改 1. 引入依赖&#xff1a; <dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artif…

Feign的介绍

Feign是springcloud里面的一个功能组件&#xff0c;那么它是实现一个什么功能呢&#xff1f; 首先我们可以先从字面意思上去理解一下它&#xff0c;Feign&#xff0c;英文翻译过来就是伪装的意思&#xff0c;实际上它的功能也是和伪装相关的&#xff0c;在我们之前在客户端配置…

@FeignClient使用详解

FeignClient标签的常用属性如下&#xff1a; name&#xff1a;指定FeignClient的名称&#xff0c;如果项目使用了Ribbon&#xff0c;name属性会作为微服务的名称&#xff0c;用于服务发现url: url一般用于调试&#xff0c;可以手动指定FeignClient调用的地址decode404:当发生h…

Feign详解

一. Feign概述 Feign是Spring Cloud提供的声明式、模板化的HTTP客户端&#xff0c; 它使得调用远程服务就像调用本地服务一样简单&#xff0c;只需要创建一个接口并添加一个注解即可。 Spring Cloud集成Feign并对其进行了增强&#xff0c;使Feign支持了Spring MVC注解&#x…

Feign(简介和使用)

1. Feign介绍 通过RestTemplate调用其它服务的API时&#xff0c;所需要的参数须在请求的URL中进行拼接&#xff0c;如果参数少的话或许我们还可以忍受&#xff0c;一旦有多个参数的话&#xff0c;这时拼接请求字符串就会效率低下 Feign是一个声明式的Web Service客户端&#…

什么是Feign?

服务间调用介绍 现有的服务调用方式 利用拼接的方式。 虽然上面有的用不错就很好了 Feign解决了什么问题 Feign的调用方式 Feign体系架构解析-武装到牙齿 上一节我们了解了feign的主要功能&#xff0c;它就像一个自拍杆一样&#xff0c;方便了Eureka的远程调用。可是怎么看…

简单理解Feign的原理与使用

文章目录 SpringCloud 总架构图一、简介1.1、负载均衡的概念2.2、Feign概念 二、入门案例2.1、导入依赖2.2、Feign的客户端2.3、调用Feign2.4、开启Feign功能2.5、启动测试2.6、Feign实现原理简单分析 三、负载均衡(Ribbon)四、熔断器支持五、请求压缩和响应压缩六、配置日志级…

Feign基本使用(超详细)

目录 一、Feign概述 二、Feign入门 1.创建服务提供者(provider) 2.创建feign接口 3、创建服务消费者(consumer) 三、Feign 原理 四、Feign优化 1、开启feign日志 2、feign超时问题 3、http连接池 4、gzip压缩 前言 当我们通过RestTemplate调用其它服务的API时&#xff0c;所…

中外黑客两则

外国一则&#xff1a;丹尼斯麦卡利斯泰尔里奇。挑选他的原因&#xff1a;帅。 &#xff08;英语&#xff1a;Dennis MacAlistair Ritchie&#xff1b;1941年9月9日&#xff0d;2011年10月12日[3][4]&#xff09;&#xff0c;著名的美国计算机科学家&#xff0c;对C语言和其他编…

git使用X篇_2_Git全套教程IDEA版(git、GitHub、Gitee码云、搭建公司内部GitLab、与IDEA集成等内容)

本文是根据以下视频及网上总结进行更新后的介绍git使用的博文。包含了git、GitHub、Gitee码云、搭建公司内部GitLab、与IDEA集成等内容。 笔记来源&#xff1a;【尚硅谷】5h打通Git全套教程IDEA版&#xff08;涵盖GitHub\Gitee码云\GitLab&#xff09; 文章目录 初识 Git0、内容…

Axure原型模板、元件库、组件库

在产品设计中&#xff0c;随时会使用到相似场景&#xff0c;每次都反复绘制耗时耗力。 若使用通用模板即可快速提高设计效率。 下面给大家提供一个登录多种验证系统框架模板&#xff0c;可快速修改使用。 预览链接&#xff1a; Axure高保真原型设计、Axure元件库、产品交互…

AXURE9最全的WEB设计元件库(分享版).rplib

Axure9常用到的WEB设计元件库&#xff0c;在Axure点击号即可导入元件库使用&#xff0c;或者打开Axure R9安装目录&#xff0c;进入DefaultSettings\Libraries&#xff0c;复制资源到此目录并重启Axure软件即可看到。 文件&#xff1a;590m.com/f/25127180-481124286-469239 &…

Axure移动端通用元件库rplib格式包含安卓、苹果各种主流手机、平板线框图元件库、IOS系统图标、人物图标、导航和分页、表格元素、各种小图标、移动元件库、axure元件库、axure原型

Axure移动端通用元件库rplib格式包含安卓、苹果各种主流手机、平板线框图元件库、IOS系统图标、人物图标、导航和分页、表格元素、各种小图标等 移动端通用元件库、app通用元件库、数据展示、操作反馈、通用模板、数据录入、列表页、表单页、详情页、通用版布局、移动端手机模…

Axure导入元件库和使用

下载元件库 vant 元件库下载: Vant - Mobile UI Components built on Vue element UI 元件库下载:https://element.eleme.cn/#/zh-CN/resource 以vant示例&#xff0c;下载完成后解压 我们看到有.rp和.rplib格式的文件 rp文件可以理解为一个别人设计好的原型作品。 rplib是原…

【Axure9.0原型实战(一)】Axure9.0的元件库的使用、导入、制作、路径等操作方法与技巧(附Axure元件库大全)

Axure9.0的元件库 文章目录 Axure9.0的元件库Axure9.0的元件库大全1.windows系统加载元件库2.MAC系统加载元件库3.新加入一些元件库4.自己建立元件库 Axure9.0的元件库大全 链接&#xff1a;https://pan.baidu.com/s/18VWM9R1qgFAXXz8Xooq4-A 提取码&#xff1a;u2gx 1.windo…

Axure RP9 的元件库

Axure的元件库 1.加载元件库 可以通过导入一些现有的元件库&#xff0c;来提高绘制的效率及美观性。 &#xff08;1&#xff09;windows系统&#xff1a; 将准备好的元件库复制到Axure 根目录下-【DefaultSettings】-【Libraries】中&#xff1b;移动成功后&#xff0c;重启…

嵌入式linux音乐电子相册制作软件,ApowerShow – 超级轻便的在线照片音乐视频制作软件...

有没有什么好用的照片视频制作软件呢&#xff1f;我大概对比了一下国内的其他软件&#xff0c;发现转场效果很多&#xff0c;但是需要自己去添加。它们的界面感觉有点繁琐&#xff0c;不是那么简洁。 其实除了使用国内的照片视频制作软件&#xff0c;你还可以使用ApowerShow。它…

html立体音乐相册源码,印记工坊立体音乐相册 v 1.8 官方版|印记工坊立体音乐相册官方版|印记工坊立体音乐相册电脑版_最火软件站...

印记工坊立体音乐相册包含多种多样的模板可以供用户使用&#xff0c;制作多种样式的电子相册,是一款傻瓜式视频音乐相册制作工具&#xff0c;及时是毫无制作经验的用户也能创作出精美的相册。最火软件站提供下载。 软件特色 故事视频制作 MV展示视频相册 时间轴视频制作 时光轴…

html动感音乐相册,动感音乐相册

动感音乐相册app是一款超级好用的音乐相册软件&#xff0c;这款软件上的功能丰富&#xff0c;能够帮助用户进行照片编辑&#xff0c;制作幻灯片等等&#xff0c;还能在线选择背景音乐进行添加&#xff0c;让相册每次打开都有不一样的感觉&#xff0c;喜欢的朋友快来下载吧。 动…