Exception: No bean named ‘userService‘ available 错误

Mistakes in the integration of pure annotations with Spring

 AnnotationConfigApplicationContext cxa = new AnnotationConfigApplicationContext("com.ConfigBean.class");

Here
should be filled in the class file.
I added """" to make it a string, remove the quotation marks

AnnotationConfigApplicationContext cxa = new AnnotationConfigApplicationContext(com.ConfigBean.class);

As well as in the creation of annotated bean factory
use

@Component  声明为spring的bean,的时候自动联想输入成了@ComponentScan找了半天才发现问题出在这。。

Guess you like

Origin blog.csdn.net/m0_49194578/article/details/112852778