spring, @resource注解注入为null

初学者,查了一个上午,要么就是spring后面的内容,要么他们的解决办法解决不了,
jdk版本17,spring版本6.0.9,代码如图,问题:@Resource注解注入为null
后面我试了试@Autowired注解,可以注入成功,Resource依旧为空

img

启用注解配置

<context:annotation-config/>

context:component-scan 标签,指定要扫描的包路径
context:annotation-config/
<context:component-scan base-package="demo.userService" />


User06 类上标有 @Component 或其他合适的注解,以便告知 Spring 将其作为一个组件进行管理