Injection of resource dependencies failed;错误几种解决方法

Error creating bean with name 'connDataController': Injection of resource dependencies failed;

最近研究ssm项目的时候出现这个问题,去网上一搜那答案真是差不多,都没有解决我的问题,后来在重复搭建项目后才发现web.xml文件没有加

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> 

没有加这个监听器,真尴尬,最重要的东西却cv掉了

其他的网上的无非就是缺这个注解却那个,还有扫描路径什么的,其实注解就跟配置文件一样挺好理解的该有的注解必须要有

比如@Service @Resource   什么的  还有@Autowired 跟@Resource   的区别自己去看看就懂了用法差不多,有些区别,

然后就是路径了比如我文件夹是 com.xxx.controller,com.xxx.service 试了下路径写com.xxx.* ,com.xxx都是可以的


猜你喜欢

转载自blog.csdn.net/qq_34735535/article/details/76053187