类型集合的 toArray 方法未定义

The method toArray is undefined for the type collection

我得到 方法 toArray is undefined for the type collection 当我有来自查询的多行时。当它只有一个 row.I am using Java 11.

时工作正常
jdbcTemplate.query(sql,
        new EntityRespRowMapper());

这是我的 RowMapper class

public class EntityRespRowMapper implements RowMapper<EntityResponse>{

  @Override
  public EntityResponsemapRow(ResultSet rs, int rowNum) throws SQLException {

    EntityResponse entity = new EntityResponse();

    entity.setEntity_id(rs.getLong("entity_id"));
    entity.setValue(rs.getString("value"));
    entity.setId(rs.getLong("id"));
    entity.setEnd_date(rs.getDate("end_date"));
    return entity ;
  }

}

我在这里做错了什么。有人可以帮我吗。我试过 QueryForList too.It 给出了同样的问题。

这是 OpenJDK 11 而非 SIT 的问题。如果将版本更改为 OpenJDK 8 或更改编译器兼容性并在 OpenJDK 8 上构建项目;此错误应该已解决。

尝试升级您的 eclipse 2019-06 及更高版本。

即使使用默认支持 Java 11 的 eclipse 2019-03 (eclipse-jee-2019-03),我也遇到了类似的问题。在调试模式下,当试图查看对象的内容时无法显示内容。

升级到 eclipse 2019-06(Java 11.0.3 和 11.0.4)允许调试对象的内容。

最新的STS应该也升级了它的eclipse(不过我没试过)