我们正在构建一个使用一组REST API的骨干应用程序.我们理想的做法是为dev和live提供不同的配置文件,这些配置文件由环境变量决定.可能吗.
提前致谢
我在 Spring Boot 中使用 OpenFeign 客户端而不使用 Ribbon 或 Eureka。我创建了一个自定义错误解码器,它按预期处理响应错误,但连接拒绝错误似乎绕过了我的自定义解码器。
PS 当我的远程服务启动时,我可以发出请求并接收响应。
我是 Java 和 Spring 的新手,我想知道是否需要用 try catch 包装我的所有调用,或者添加我的自定义错误处理程序应该可以捕获错误,因为在一个地方处理所有错误似乎更清晰
public class FeignErrorDecoder implements ErrorDecoder {
private final ErrorDecoder defaultErrorDecoder = new Default();
@Override
public Exception decode(String methodKey, Response response) {
if (response.status() >= 400 && response.status() <= 499) {
//handle with custom exception
}
if (response.status() >=500) {
//handle with custom exception
}
return defaultErrorDecoder.decode(methodKey, response);
}
}
Run Code Online (Sandbox Code Playgroud)
@Configuration
public class FeignConfig {
//other beans here
@Bean
public ErrorDecoder feignErrorDecoder() …Run Code Online (Sandbox Code Playgroud)