<!-- hystrix -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
注意:这个依赖可以不加,因为Feign默认已经包含了hystrix功能。
## feign启用hysrix
feign.hystrix.enabled=true
package com.mazong.serverbloguser.service.impl;
import com.mazong.serverbloguser.service.IUserService;
@Component
public class IUserServiceImpl implements IUserService {
//
public String hello() {
return "feign(hello):降级了";
}
}
package com.mazong.serverbloguser.service;
import com.mazong.serverbloguser.service.impl.IUserServiceImpl;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
@FeignClient(value = "server-blog-article", fallback = IUserServiceImpl.class)
@Component(value = "iUserService")
public interface IUserService {
@RequestMapping(value = "/hello")
public String hello();
}