出现 org.springframework.beans.factory.BeanCreationException 异常的原因及解决方法
1 异常描述
在从 SVN 检出项目并配置完成后,启动 Tomcat 服务器,报出如下错误:
2 异常原因
通过观察上图中被标记出来的异常信息,咱们可以知道
org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘XXX’
此异常,为:注入 bean 失败异常。
说白了,出现这个异常,就是找不到对应的 bean 啦!能够导致 bean 注入失败的原因包括以下几种但不限于这几种:
- 对应的 bean 没有添加注解;
- 对应的 bean 添加注解错误,例如将 Spring 的
@Service错选成 dubbo 的; - 选择错误的自动注入方法等。
- 一般在项目中出现的问题很多种,归根结底还是没有找到资源
3 解决方法
既然知道了出现此异常的原因,那我们就回过头来,去看看对应的 Bean 声明,观察后发现注入 Facade 的代码为:
@Autowired
ErrorCodeFacade errorCodeFacade;
好吧,错误也就出在了这里!一般来说,在注入 service 层和 biz 层接口的时候,可以用@Autowired,例如:
@Autowired
ErrorCodeService errorCodeService;
但是,在注入 Facade 层接口的时候,应该用RemoteServiceFactory.getService(),例如:
ErrorCodeFacade errorCodeFacade = RemoteServiceFactory.getService(ErrorCodeFacade.class);
也就是说,对于这个异常,采用上述代码声明 ErrorCodeFacade 后,即可解决。
出现 org.springframework.beans.factory.BeanCreationException 异常的原因及解决方法的更多相关文章
- 异常将上下文初始化事件发送到类的侦听器实例.[org.springframework.web.context.ContextLoaderListener] org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in class p
严重: 异常将上下文初始化事件发送到类的侦听器实例.[org.springframework.web.context.ContextLoaderListener]org.springframework ...
- 开发Spring过程中几个常见异常(二):Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'a' define
本异常是小编在运行自己另外一篇博文中的例子时遇到的.(附博文:http://www.cnblogs.com/dudududu/p/8482487.html) 完整异常信息: 警告: Exception ...
- mvn ssm 异常 org.springframework.beans.factory.BeanCreationException:Error creating bean with name 'multipartResolver'
解决方案: 添加 commons-fileupload-1.2.jar <!-- https://mvnrepository.com/artifact/commons-fileupload/co ...
- 错误/异常:org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/beans_common.xml]...的解决方法
1.第一个这种类型的异常 1.1.异常信息:org.springframework.beans.factory.BeanCreationException: Error creating bean w ...
- org.springframework.beans.factory.BeanCreationException 解决异常错误
一月 18, 2017 10:18:51 上午 org.apache.coyote.http11.Http11Protocol initINFO: Initializing Coyote HTTP/1 ...
- org.springframework.beans.factory.BeanCreationException
org.springframework.beans.factory.BeanCreationException 这个是创建bean的异常. 我所遇到的情况是由下面这个引起的: @Resource an ...
- Context initialization failed org.springframework.beans.factory.BeanCreationException
严重: Context initialization failed org.springframework.beans.factory.BeanCreationException: Error cre ...
- 【解决方案】 org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'userHandler': Injection of resource dependencies failed;
一个错误会浪费好多青春绳命 鉴于此,为了不让大家也走弯路,分享解决方案. [错误代码提示] StandardWrapper.Throwableorg.springframework.beans.fac ...
- Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.BeanCreationException:
严重: Exception sending context initialized event to listener instance of class org.springframework.we ...
随机推荐
- F2eTest程序快捷方式安装到桌面
按照http://f2etest.***.com/install页面上介绍的:安装快捷方式到Windows桌面 (Win7)部分的介绍进行安装. 其中第三步的https连接需要在f2etest的c ...
- 解决Visual Studio 2015启动慢的问题
总发现vs2015经常把cpu给占满了,导致电脑卡的不要不要的.这是CodeLens引起的,因为装了VAssistX后,感觉CodeLens还没VAssistX好使.所以,关了CodeLens就可以了 ...
- CAN--UART的协议转换器
CAN--UART的协议转换器 //------------------------------------------------------// CAN <==> UART的协议转换 ...
- java 解析http user-agent 信息
解析http user-agent信息,使用uasparser-0.6.1.jar和jregex-1.2_01.jar两个包 import cz.mallat.uasparser.OnlineUpda ...
- 美团热修复Robust-源码篇
上一篇主要分析了Robust的使用方法,这一篇就来总结一下Robust的源码分析. 我个人倾向于将Robust框架分为两个部分,自动插入代码和动态加载Patch. 一.Robust源码分析 目前我的分 ...
- iOS开发用如何用类"SKStoreProductViewController"跳转AppStore点赞评分?
大家都知道,评论和评分是决定app在appstore中排名的重要因素,但是大部分用户下载安装APP后却不会去点评,所以添加提示用户去点评的功能是很必要的. 目前,AppStore点赞评分有两种方法,一 ...
- Xcode解决“Implicit declaration of function 'XXX' is invalid in C99” 警告或报错
1.Build Setting>>>C Language Dialect,然后选择GNU99[-std=gnu99] (选择看项目实际要求). 2.Build Setting> ...
- 在Linux中连接android设备
1.用usb线连接电脑和android设备,在命令行中输入lsusb可查看采用usb连接到电脑的设备 找到设备的vendor ID. 如上图: "Bus 002 Device 007: ID ...
- NGS检测SNP
1,Fastq数据质控 2,Fastq转化成bam,包含头文件 bwa aln ref.fa test_1.fq > test_1.sai bwa aln ref.fa test_2.fq &g ...
- Verilog_Day2_Plus
内容为书中第4章 等式运算符 “==” 与 “===” 的区别 Verilog中存在4种等式运算符: == (等于); != (不等于); === (等于); !== (不等于). “==”与&quo ...