通过Feign调用的方法实现接口之间的传递

1、接口的写法

@FeignClient(name = "yzf-cloud-finance-center", url = "192.168.1.32:8912", fallback = FundFeignClientServiceFallBack.class)
public interface FundFeignClientService {

	@RequestMapping(value = "/tenantdb/accountBook/getBeginMoney", method = RequestMethod.POST)
	public long getBeginMoney(@RequestHeader("tenantUid") String tenantUid, @RequestParam("accSetUid") String accSetUid,
			@RequestParam("subIsn") String subIsn, @RequestParam("fromPeriod") String fromPeriod,
			@RequestParam("toPeriod") String toPeriod);
}

2、实现类的写法

@Component
public class FundFeignClientServiceFallBack implements FundFeignClientService{
	private static final Logger logger = LoggerFactory.getLogger(FundFeignClientServiceFallBack.class);

	@Override
	public long getBeginMoney(String tenantUid,String accSetUid, String subIsn, String fromPeriod, String toPeriod) {
		logger.error("feign执行方法getBeginMoney({})异常");
		return 0;
	}
}


你可能感兴趣的:(java)