1.编写功能类的Bean

Spring出现:No qualifying bean of type [com.exe.demo01.ch1.di.UseFunctionService] is defined的解决办法

2.使用功能类的Bean

Spring出现:No qualifying bean of type [com.exe.demo01.ch1.di.UseFunctionService] is defined的解决办法

3.配置类

Spring出现:No qualifying bean of type [com.exe.demo01.ch1.di.UseFunctionService] is defined的解决办法

4.运行

Spring出现:No qualifying bean of type [com.exe.demo01.ch1.di.UseFunctionService] is defined的解决办法

以上为正确的代码!

出现No qualifying bean of type [com.exe.demo01.ch1.di.UseFunctionService] is defined错误的原因如下:

1.在配置类中忘记扫描包,或扫描的包路径写错

Spring出现:No qualifying bean of type [com.exe.demo01.ch1.di.UseFunctionService] is defined的解决办法

2.在运行的main方法中,.使用AnnotationConfigApplicationContext作为Spring容器,接受输入一个配置类作为参数,这个参数配置错误

Spring出现:No qualifying bean of type [com.exe.demo01.ch1.di.UseFunctionService] is defined的解决办法

相关文章: