问题一:Could not autowire.No beans of “NamedParameterJdbcTemplate‘ type found.
问题分析:
在 Idea 的 spring 工程里,遇到 Could not autowire.No beans of “NamedParameterJdbcTemplate‘ type found. 的错误提示。但程序的编译和运行都是没有问题的,不影响业务功能。
问题原因:
(1)第一个是 Intellij IDEA 本身工具的问题。这种情况下不用去理会。
(2)在注解上加上:
@Autowired(required = false)
(3)降低 Autowired 检测的级别,将 Severity 的级别由之前的 error 改成 warning 或其它可以忽略的级别。
问题二:Field injection is not recommended
解决办法:
Settings =》 Editor =》 Inspections =》 Spring=》 Spring Core =》 Code=》 Non recommended ‘field’ injections,将 Non recommended 'field' injections勾选掉
,如下图:
最终结果: