使用@FeignClient标注一个远程调用的类,
@Component
@FeignClient(name = "${remote.feign.edu-authority-boot.name:edu-authority-boot}", path = "/auth",
fallbackFactory = AuthProviderFallbackFactory.class)
public interface AuthProvider
在本项目的其他类中使用@Autowired注入AuthProvider时,提示找不到此类,说明在SpringIOC容器中没有此类。
原因为:@FeignClient标注的类,在SpringBoot的启动类,需要加入注解:
@EnableFeignClients(basePackages = "com.my.edu")
结局办法:
在SpringBoot启动类加入注解:
@EnableFeignClients(basePackages = "com.my.edu")