运行maven项目报错:The method queryForInt(String) is undefined for the type JdbcTemplate

来源:互联网 发布:淘宝上传3c认证入口 编辑:程序博客网 时间:2024/05/29 12:42
报错:The method queryForInt(String) is undefined for the type JdbcTemplate
The method JdbcTemplate.queryForInt was deprecated in Spring 3.2.2 and it was removed in Spring 4.2.0.

问题:spring.jar包问题,spring3.2.2支持 queryForInt(String) 方法,但spring4.2.0不支持这个方法,他只支持 queryForObject(String sql, class<T> requiredType) 这个方法。

解决方法:将spring版本降到spring3.2.2,若为maven项目,可在pom.xml将spring依赖中spring的Version改为3.2.2;或者将自己报错处使用的方法换成queryForObject(String sql, class<T> requiredType)。
阅读全文
0 0