我在FallBackFactory中找到异常原因时遇到问题,我的是一个旧的应用程序,所以我不能使用spring cloud方法(带注释等)。
我找到了以下解决方案,但仍然不适合我: Issue in getting cause in HystrixFeign client fallback
这是我的代码:
public static class ProfileFallbackFactory implements ProfileProxy, FallbackFactory<ProfileFallbackFactory> {
final Throwable cause;
public ProfileFallbackFactory() {
this(null);
}
ProfileFallbackFactory(Throwable cause) {
this.cause = cause;
}
@Override
public ProfileFallbackFactory create(Throwable cause) {
LOG.info("Profile fallback create "+cause);
return new ProfileFallbackFactory(cause);
}
public Profile getProfile(String id) {
}
实例创建:
profileProxy = new HystrixFeign.Builder().setterFactory(new CustomSetterFactory())
.decode404()
.decoder(new GsonDecoder(gsonWithDateFormat))
.encoder(new GsonEncoder(gsonWithDateFormat))
.errorDecoder(new profileProxyErrorDecoder())
.target(ProfileProxy.class,profileServiceUrl, (FallbackFactory<ProfileFallbackFactory>)new ProfileFallbackFactory());
ProfileProxyErrorDecoder类中添加了一个记录器,但在日志中找不到此记录器。我可以在服务器日志中看到com.netflix.hystrix.exception.HystrixRuntimeException
有人可以指出我哪里出错了吗?