日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Fegion-3覆写Fegion的默认配置及Fegion的日志

發布時間:2024/4/13 编程问答 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Fegion-3覆写Fegion的默认配置及Fegion的日志 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
http://10.40.8.152:8761/eureka/apps后面跟上服務的名稱http://10.40.8.152:8761/eureka/apps/MICROSERVICE-CONSUMER-MOVIE-RIBBON10.40.8.152:8761/eureka/apps/microservice-simple-provider-userlocalhost:7900/simple/1https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-feign.html7.8 Feign request/response compressionFeign還支持響應的壓縮,也就是GZIPYou may consider enabling the request or response GZIP compression for your Feign requests. You can do this by enabling one of the properties:非常簡單feign.compression.request.enabled=truefeign.compression.response.enabled=true最后來講一下Feign的日志7.9 Feign logging我們首要知道Feign的默認日志級別是什么A logger is created for each Feign client created. By default the name of the logger is the full class name of the interface used to create the Feign client. Feign logging only responds to the DEBUG level.application.yml. logging.level.project.user.UserClient: DEBUG就是你這邊得設置Debug level,Feign才會響應logging.level.com.learn.cloud.feign.UserFeignClient=DEBUGlocalhost:8010/movie/1localhost:8010/MICROSERVICE-CONSUMER-MOVIE-RIBBONlocalhost:7900/simple/1The Logger.Level object that you may configure per client, tells Feign how much to log. Choices are:NONE, No logging (DEFAULT).BASIC, Log only the request method and URL and the response status code and execution time.HEADERS, Log the basic information along with request and response headers.FULL, Log the headers, body, and metadata for both requests and responses. <?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 http://maven.apache.org/xsd/maven-4.0.0.xsd"><modelVersion>4.0.0</modelVersion><artifactId>microservice-consumer-movie-feign-customizing</artifactId><version>0.0.1-SNAPSHOT</version><packaging>jar</packaging><name>microservice-simple-consumer-movie</name><description>Demo project for Spring Boot</description><parent><groupId>cn.learn</groupId><artifactId>microcloud02</artifactId><version>0.0.1</version></parent><properties><project.build.sourceEncoding>UTF-8</project.build.sourceEncoding><project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding><java.version>1.8</java.version></properties><dependencies><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-data-redis</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-eureka</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-feign</artifactId></dependency></dependencies><build><plugins><plugin><groupId>org.springframework.boot</groupId><artifactId>spring-boot-maven-plugin</artifactId></plugin></plugins></build></project> #debug=true server.port=8010eureka.client.serviceUrl.defaultZone=http://admin:1234@10.40.8.152:8761/eurekaspring.application.name=microservice-consumer-movie-ribbon eureka.instance.prefer-ip-address=true eureka.instance.instance-id=${spring.application.name}:${spring.cloud.client.ipAddress}:${spring.application.instance_id:${server.port}} eureka.client.healthcheck.enabled=true spring.redis.host=10.40.8.152 spring.redis.password=1234 spring.redis.port=6379#stores.ribbon.listOfServers=10.40.8.144:7900logging.level.com.learn.cloud.feign.UserFeignClient=DEBUG package com.learn.config;import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;import feign.Contract; import feign.Logger;@Configuration public class Configuration1 {@Beanpublic Contract feignContract() {return new feign.Contract.Default();}@BeanLogger.Level feignLoggerLevel() {return Logger.Level.FULL;} } package com.learn.config;import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration;import feign.auth.BasicAuthRequestInterceptor;@Configuration public class Configuration2 {@Beanpublic BasicAuthRequestInterceptor basicAuthRequestInterceptor() {return new BasicAuthRequestInterceptor("admin", "1234");} } package com.learn.cloud.feign;import org.springframework.cloud.netflix.feign.FeignClient; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RequestMapping;import com.learn.config.Configuration2;@FeignClient(name = "xxxx", url = "http://10.40.8.152:8761/", configuration = Configuration2.class) public interface FeignClient2 {@RequestMapping(value = "/eureka/apps/{serviceName}")public String findServiceInfoFromEurekaByServiceName(@PathVariable("serviceName") String serviceName); } package com.learn.cloud.feign;import org.springframework.cloud.netflix.feign.FeignClient;import com.learn.cloud.entity.User; import com.learn.config.Configuration1;import feign.Param; import feign.RequestLine;@FeignClient(name="microservice-simple-provider-user", configuration = Configuration1.class) public interface UserFeignClient {@RequestLine("GET /simple/{id}")public User findById(@Param("id") Long id); } package com.learn.cloud.controller;import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.RestController;import com.learn.cloud.entity.User; import com.learn.cloud.feign.FeignClient2; import com.learn.cloud.feign.UserFeignClient;@RestController public class MovieController {@Autowiredprivate UserFeignClient userFeignClient;@Autowiredprivate FeignClient2 feignClient2;@GetMapping("/movie/{id}")public User findById(@PathVariable Long id) {return this.userFeignClient.findById(id);}@GetMapping("/{serviceName}")public String findServiceInfoFromEurekaByServiceName(@PathVariable String serviceName) {return this.feignClient2.findServiceInfoFromEurekaByServiceName(serviceName);}} package com.learn.cloud;import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.cloud.netflix.eureka.EnableEurekaClient; import org.springframework.cloud.netflix.feign.EnableFeignClients;@SpringBootApplication @EnableEurekaClient @EnableFeignClients public class ConsumerMovieFeignApplication {public static void main(String[] args) {SpringApplication.run(ConsumerMovieFeignApplication.class, args);} }

?

總結

以上是生活随笔為你收集整理的Fegion-3覆写Fegion的默认配置及Fegion的日志的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。