@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