zoukankan      html  css  js  c++  java
  • 解决BeanNotOfRequiredTypeException: Bean named 'XXX' must be of type XXX, but was actually of type XXX问题

      Java新手,困扰了一下午。

      发布时总是报这样一个错误。

    org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'XXX': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'XXX' must be of type [XXXX], but was actually of type [XXXXX]
    at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:306)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1106)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:517)
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:456)
    at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:294)
    Caused by: org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'XXX' must be of type [XXXX], but was actually of type [XXXXX]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:360)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
    at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:269)
    at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)

    最后找到原因:action中引用的包名,与spring bean注册文件中注册的包不一致,导致action没有引用到目标包,反而引用一个错误的包(旧包)。

    解决方法:确定要引用的新的包名,在action中去掉无错的import,重新import新的包。

  • 相关阅读:
    linux shell 获取文件夹全文绝对路径
    Selenium自动化获取WebSocket信息
    Automatically generating nice graphs at end of your Load Test with Apache JMeter and JMeter-Plugins
    卡夫卡与风暴:卡夫卡和风暴的明智比较
    Apache Kafka安全| Kafka的需求和组成部分
    Kafka Schema Registry | 学习Avro Schema
    QT 内部使用函数列表
    QT图标添加
    QT快捷键
    QT软件上架以及自启动
  • 原文地址:https://www.cnblogs.com/guodongdidi/p/6171024.html
Copyright © 2011-2022 走看看