@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);
	}
}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM