报错解决Context initialization failed

时间:2025-03-09 08:01:49

今天打包完工程,放到Resin服务器上运行,发现Context initialization failed报错;看了一下报错信息,是将service层的某类注入到Controller层时有问题。错误提示中的原因
Caused by: : No qualifying bean of type [***Service] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency.
可以定位到对应的类,发现是遗忘了对该类进行bean定义或者用Spring注解@service;
解决方式:1.可以在spring的配置文件中使用bean id进行定义;
2.在该类增加@service注解;
报错信息如下:

[ERROR][2017-07-06 11:34:37,878][]Context initialization failed
: Error creating bean with name '***Controller': Injection of autowired dependencies failed; nested exception is : Could not autowire field: private ***Service ***Service; nested exception is : No qualifying bean of type [***Service] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@(required=true)}
    at (:292)
    at (:1185)
    at (:537)
    at (:475)
    at $1.getObject(:304)
    at (:228)
    at (:300)
    at (:195)
    at (:700)
    at (:760)
    at (:482)
    at (:658)
    at (:624)
    at (:672)
    at (:543)
    at (:484)
    at (:136)
    at (:70)
    at (:1359)
    at (:1255)
    at (:1206)
    at (:251)
    at (:3798)
    at $700(:208)
    at $StartupTask.run(:5318)
    at .thread2.(:173)
    at .thread2.ResinThread2.run(:118)
Caused by: : Could not autowire field: private ***Service ***Controller.***Service; nested exception is : No qualifying bean of type [***Service] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@(required=true)}
    at $(:508)
    at (:87)
    at (:289)
    ... 26 more
Caused by: : No qualifying bean of type [***Service] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@(required=true)}
……

相关文章