bug分析
java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class com.lwh.pojo.Account 报错翻译
java.lang.ClassCastException: class java.util.ArrayList不能被转换为class com.lwh.pojo.Account
其实就是list类型的数据不能转化成实例型的
错误情况
解决方案
@Override
public Account findByid(int id) {
List < Account> accounts = getJdbcTemplate().query("select * from account1 where id=?", new BeanPropertyRowMapper<Account>(Account.class) ,id);
return accounts.get(0);//加个get(0)返回第一个实例就行了
}