老师我在ProductClient 添加fallback后如下:
@FeignClient(name = "product",fallback = ProductClientFallBack.class)
public interface ProductClient {
@GetMapping("/msg")
String productMsg();
@PostMapping("/product/listForOrder")
List<ProductInfoOutput> listForOrder(List<String> productIdList);
@PostMapping("/product/decreaseStock")
void decreaseStock(List<DecreaseStockInput> cartDTOList);
}
package com.agile.product.client;
import com.agile.product.common.DecreaseStockInput;
import com.agile.product.common.ProductInfoOutput;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* Feign Hystrix
*/
@Component
public class ProductClientFallBack implements ProductClient{
@Override
public String productMsg() {
return null;
}
@Override
public List<ProductInfoOutput> listForOrder(List<String> productIdList) {
return null;
}
@Override
public void decreaseStock(List<DecreaseStockInput> cartDTOList) {
}
}
OrderServiceImpl
类中的 productClient 引用就有问题了呢?
启动类中添加了的
@ComponentScan(basePackages = "com.agile")
后来看了下, 就是因为我添加ProductClient接口类的实现类
SpringCloud组件实现微服务,【已升级Finchley.Release】
了解课程