FeignClient报错:quired a bean of type ‘com.csg.sdc.frontend.facade.client.VesselClient‘ that could not

spring boot写了一个FeignClient,启动项目时报错

Description:

Field vesselClient in com.csg.sdc.frontend.service.CustomUserFocusService required a bean of type 'com.csg.sdc.frontend.facade.client.VesselClient' that could not be found.


Action:

Consider defining a bean of type 'com.csg.sdc.frontend.facade.client.VesselClient' in your configuration.

根据英文的提示是在配置中找不到一个指定自动注入类型的bean,经过多方排查得出结论:
正常情况下加上FeignClient注解的类会自动被Spring扫描到生成Bean注册到spring容器中,既然他说没找到,也就是该注解被没有被spring识别,问题的核心关键就在application类的注解SpringBootApplication上:

@EnableFeignClients(basePackages = {"com.csg.sdc.frontend.feign"})

注意FeignClient需要在此扫描的包路径下。

package com.csg.sdc.frontend;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.openfeign.EnableFeignClients;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.EnableAspectJAutoProxy;

@SpringBootApplication(scanBasePackages = {"com.csg.sdc"})
@EnableFeignClients(basePackages = {"com.csg.sdc.frontend.feign"})
@EntityScan({"com.csg.sdc.admin.base.domain","com.csg.sdc.frontend.domain"})
@EnableDiscoveryClient
@EnableAspectJAutoProxy(exposeProxy = true)
public class FrontendApplication {
    public static void main(String[] args) {
        ApplicationContext context = SpringApplication.run(FrontendApplication.class);
    }
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值