Exception: No bean named ‘userService‘ available 错误

纯注解集成Spring后出的失误

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

这里
应该填入class文件的
我给加了“”“”导致成为字符串,拿掉引号

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

还有在创建bean工厂注解的时候
使用

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

猜你喜欢

转载自blog.csdn.net/m0_49194578/article/details/112852778
今日推荐