错误代码
使用JdbcTemplate查询
代码语言:javascript复制 String sql="SELECT t.industry_code AS item, COUNT (1) AS intValue FROM company_info t GROUP BY industry_code";
List<LineChartShowBean> pollutionCityBeans = trJdbcTemplate.queryForList(sql, LineChartShowBean.class);
代码语言:javascript复制queryForList的第二个参数Class<T> elementType仅仅是Integer,String之类的数据类型,使用如下方法可以获得自己想要的结果:
正确的代码
代码语言:javascript复制String sql="SELECT t.industry_code AS item, COUNT (1) AS intValue FROM company_info t GROUP BY industry_code";
List<LineChartShowBean> list = trJdbcTemplate.query(sql,
new BeanPropertyRowMapper<>(LineChartShowBean.class));