springboot项目中在普通类中注入bean的问题
#springboot项目中在普通类中注入bean直接在普通类中使用@Autowired注入bean,会导致注入的对象为null。这是因为普通类无法通过@Autowired注入bean,使用@Autowired注入bean要求这个类也注入到spring容器中,交给容器管理。##解决方法一:新建一个spring工具类参考博客:https://blog.csdn.net/weixin_42805929/article/details/116062432?utm_medium=distribute.pc_a
原创
2022-06-02 17:36:30 ·
1323 阅读 ·
1 评论