FactoryBean threw exception on object creation,FeignClient无法注入bean,bsun.misc.Unsafe.park异常

[BUG]记一个FeignClient无法注入bean的错误

springcloud启动报错,错误log如下

2020-06-03 16:25:21.551  WARN 28596 --- [           main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'utils': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.emis.education.service.module.UserServer': FactoryBean threw exception on object creation; nested exception is java.lang.ArrayIndexOutOfBoundsException: 1
2020-06-03 16:25:21.554  INFO 28596 --- [           main] j.LocalContainerEntityManagerFactoryBean : Closing JPA EntityManagerFactory for persistence unit 'default'
2020-06-03 16:25:21.555  WARN 28596 --- [           main] o.s.b.f.support.DisposableBeanAdapter    : Invocation of destroy method 'close' failed on bean with name 'eurekaRegistration': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'org.springframework.cloud.netflix.eureka.EurekaClientAutoConfiguration$RefreshableEurekaClientConfiguration': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)
2020-06-03 16:25:21.556  INFO 28596 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown initiated...
2020-06-03 16:25:21.561  INFO 28596 --- [           main] com.zaxxer.hikari.HikariDataSource       : HikariPool-1 - Shutdown completed.
2020-06-03 16:25:21.562  INFO 28596 --- [           main] o.apache.catalina.core.StandardService   : Stopping service [Tomcat]

查阅网上的资料无果,大部分方案是指向找不到bean,但是我的情况是已经指定了入口文件的@EnableFeignClients,只是依赖无法注入。
最后发现问题起因是在路由层的一个方法与父类冲突或循环引用??根源没有找到,但是我是这样改的,希望对类似的问题有帮助
修改前

// 子类
@Api(tags = "xx")
@RestController
@RequestMapping("xx")
public class ExamPaperController extends BaseController<xxx,xxx,xxx> {

  @PostMapping("xxx")
  @ApiOperation("xx")
  public void create(@RequestParam("file") MultipartFile file,@PathVariable Long chapter)  {
    // TODO: 
  }
}

// 父类
@Component
public class BaseController<S extends BaseService<?>,C,U> {

  @PostMapping("")
  @ApiOperation("create")
  public void create(@RequestBody C body) throws NotFoundException {
    this.verify(Thread.currentThread() .getStackTrace()[1].getMethodName(),body);
    S service = this.getService();
    service.create(body);
  }
}

修改后(修改方法名)

// 子类
@Api(tags = "xx")
@RestController
@RequestMapping("xx")
public class ExamPaperController extends BaseController<xxx,xxx,xxx> {

  @PostMapping("xxx")
  @ApiOperation("xx")
  public void createXXX(@RequestParam("file") MultipartFile file,@PathVariable Long chapter)  {
    // TODO: 
  }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值