关于本次【Unsatisfied dependency expressed through field 'iClientFeignEmployeeService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.oppo】

关于本次springboot项目上线遇到的问题归纳:

1.本地合适但是线上扫不到包,报错:【Unsatisfied dependency expressed through field 'iClientFeignEmployeeService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.oppo.csc.hrms.client.service.employee.IClientFeignEmployeeService】

  原因:扫不到manager里面的包、导致出现问题

  解决前:

@SpringBootApplication(scanBasePackages = {"com.oppo.csc.sso", "com.xiniaoyun.external"}, exclude = {NacosConfigEndpointAutoConfiguration.class})    //就是此处扫描包的
@EnableSpringDataWebSupport
@EnableScheduling
@EnableFeignClients({"com.xiniaoyun.external.client","com.xiniaoyun.shared", "com.oppo.csc.sso.api", "com.oppo.csc.hrms","com.xiniaoyun.helios"})
@MapperScan(value = "com.xiniaoyun.external.dao", annotationClass = Mapper.class)
@EnableDiscoveryClient
public class SummerExternalApplication {
    private static ApplicationContext applicationContext;

    public static ApplicationContext getApplicationContext() {
        return applicationContext;
    }

    public static void main(String[] args) {
        applicationContext = SpringApplication.run(SummerExternalApplication.class, args);
    }
}

解决后:

@SpringBootApplication(scanBasePackages = {"com.oppo.csc.sso", "com.xiniaoyun.external.manager","com.xiniaoyun.external"}, exclude = {NacosConfigEndpointAutoConfiguration.class}) //单独将manager的包扫描一次、后面再扫全局。
@EnableSpringDataWebSupport
@EnableScheduling
@EnableFeignClients({"com.xiniaoyun.external.client","com.xiniaoyun.shared", "com.oppo.csc.sso.api", "com.oppo.csc.hrms","com.xiniaoyun.helios"})
@MapperScan(value = "com.xiniaoyun.external.dao", annotationClass = Mapper.class)

这样就能解决掉该问题、主要的原因就是没有扫描到包、导致出现的问题。

猜你喜欢

转载自www.cnblogs.com/mzlb520/p/12119382.html