@EnableFeignClients 注解

feignClents在spring容器里找不到的原因

  • 当使用的feignClents 来自引用别的工程时,需要指定包名,如果不指定就算使用ComponentScan 扫描也不行

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.annotation.ComponentScan;

/**
 * @describe: 消费者服务启动类
 * @author: zhuchunwang
 * @date: 2019/3/7 16:08
 */
@SpringBootApplication
@EnableDiscoveryClient
/**
 * 如果不写包名默认找启动类包下面的feignClient
 */
@EnableFeignClients("com.wdcloud.rps.common.*")
@ComponentScan(basePackages = {"com.wdcloud.rps.common","com.wdcloud.rps.consumer"})
public class  ConsumerApplication {
	public static void main(String[] args) {
		SpringApplication.run(ConsumerApplication.class,args);
	}
}

posted on 2019-03-12 15:38  朱春旺  阅读(19021)  评论(0编辑  收藏  举报