本地调试时指定本地windows启动的feign调用,屏蔽测试环境的服务干扰
@Component
@Data
public class Debug {
public static void initConfigFeign() {
System.setProperty("config.debug.url.test", "http://127.0.0.1:8081");
System.setProperty("eureka.client.register-with-eureka", "false");
}
public static boolean getDebug() {
String os = System.getProperties().getProperty("os.name");
return (null != os && os.toLowerCase().contains("windows"));
}
}
@SpringBootApplication
@EnableFeignClients
public class TestApplication{
public static void main(String[] args) {
if (Debug.getDebug()) {
Debug.initConfigFeign();
}
SpringApplication.run(TestApplication.class, args);
}
}
@FeignClient(value = "user-test",url = "${config.debug.url.test}",configuration ={FeignConfig.class})
@Configuration
@Slf4j
public class FeignConfig {
@Bean
public Retryer feignRetryer() {
log.info("feignConfig....>>>>feignRetryer...........");
return new Retryer.Default(200, 200, 0);
}
@Bean
Request.Options feignOptions() {
return new Request.Options(5 * 1000, 60 * 1000);
}
@Bean
public Feign.Builder feignBuilder() {
return Feign.builder().retryer(Retryer.NEVER_RETRY);
}
@Bean
public Logger.Level multipartLoggerLevel() {
return Logger.Level.FULL;
}
}