跟着视频UserController调UserService为啥报错呀
跟着视频UserController调UserService为啥报错呀
跟着视频UserController调UserService为啥报错呀
目测 applicationContext.xml 配置了如下的 bean
<bean id = "userService" class="com.itheima.demo.UserController"/>
可以尝试改成如下的配置
<bean id = "userService" class="com.itheima.service.impl.UserServiceImpl"/>
你这是注入的 UserController 是以 “userService” 注入进去的吧
看下你的配置文件
这个东西不能在main方法里调用,spring 有自己底层的一套机制,可以使用@Test注解
1、估计有些地方,你看漏了
2、估计视频搞漏了;
不管是哪里出错,你都需要自己检查;
然后,如果是视频错了,你可以说出来,让我们一起唾弃他;
但我个人觉得,你看漏了哪些地方,是比较大几率的
把applicationContext配置文件发的看下
UserServiceImpl实现了UserService吗? 可以试着改为
@Service
pblic class UserServiceImpl implments UserService{}
或者
@Service("userService")
pblic class UserServiceImpl{}
@ Service注入一下
applicationContext.xml里的userService配置错了