2023-11-02 15:08:58.703 WARN  --- [main] o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext : [] Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'axxxController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'axxxFacadeImpl': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.xx.support.feign.UxxxFeign' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@javax.annotation.Resource(shareable=true, lookup=, name=, description=, authenticationType=CONTAINER, type=class java.lang.Object, mappedName=)}
2023-11-02 15:08:58.713 INFO  --- [main] o.a.catalina.core.StandardService : [] Stopping service [Tomcat]
2023-11-02 15:08:58.748 INFO  --- [main] o.s.b.a.l.ConditionEvaluationReportLoggingListener : [] 

Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2023-11-02 15:08:59.223 ERROR --- [main] o.s.b.d.LoggingFailureAnalysisReporter : [] 

***************************
APPLICATION FAILED TO START
***************************

Description:

A component required a bean of type 'com.xx.support.feign.UxxxOFeign' that could not be found.


Action:

Consider defining a bean of type 'com.xx.support.feign.UxxxFeign' in your configuration.

Disconnected from the target VM, address: '127.0.0.1:3950', transport: 'socket'

Process finished with exit code 1

这是Feign接口的找不到bean,而不是其他类,这时候无论你写多少@Component都是没用的。

正确的解决方案是在启动类上做手段

@EnableJdSwagger2
@ComponentScan(basePackages = {"com.xx"})
@MapperScan("com.xx.xx.dao.mapper")
@EnableTransactionManagement(proxyTargetClass = true)
@SpringBootApplication(exclude = {DruidDataSourceAutoConfigure.class})
@EnableFeignClients(basePackages = { "com.xx.xx.services.integration"})
@EnableAsync
public class PxxxiApplication {

    public static void main(String[] args) {
        SpringApplication.run(PxxxiApplication.class, args);
    }
}
// 这个路径一定要能扫描到,看源码会发现他是个数组,意味着你可以传多个
@EnableFeignClients(basePackages = { "com.xx.xx.services.integration"})
分类: java

站点统计

  • 文章总数:309 篇
  • 分类总数:19 个
  • 标签总数:191 个
  • 运行天数:1009 天
  • 访问总数:128901 人次

浙公网安备33011302000604

辽ICP备20003309号