学习spring JdbcTemplate 运行一直报如下错误

原因是
RowMapper rowMapper = new BeanPropertyRowMapper(); 没有指定加载类
改成
RowMapper rowMapper = new BeanPropertyRowMapper(Book.class);
即可解决
Spring JdbcTemplate报错 class was not specified; nested exception is java.lang.IllegalStateException
最新推荐文章于 2024-08-28 10:25:15 发布
本文介绍了在使用SpringJdbcTemplate时遇到的一个常见错误,即在创建BeanPropertyRowMapper实例时没有指定对应的类。通过将代码改为`RowMapper rowMapper = new BeanPropertyRowMapper<>(Book.class);`,问题得到了解决。这个错误通常发生在尝试从数据库查询结果映射到Java对象时,正确的指定类能确保正确地映射数据。

1186

被折叠的 条评论
为什么被折叠?



