问题:

因工作需要,在MyEclipse现有项目中导入一段代码,代码片段引用了Lambda表达式,如下:

    @Test
    public void test01() throws IOException {
        DeptMapper deptMapper = session.getMapper(DeptMapper.class);
        Dept dept = new Dept();
        dept.setDeptno(2);
        dept.setDname("test2");
        List<Dept> list = deptMapper.findList1(dept);
        list.forEach(item -> System.out.println(item));
    }

编译时出错:【Lambda expressions are allowed only at source level 1.8 or above】

解决:

鼠标右键单击项目属性【Properties】,在出现的窗口中,选择【Java Compiler】,将【Compiler  compliance Level】改为1.8以上即可。如下图:

MyEclipse,【Lambda expressions are allowed only at source level 1.8 or above】编译错误的解决

 

相关文章:

  • 2021-10-03
  • 2021-10-15
  • 2022-12-23
  • 2021-12-10
  • 2021-09-25
猜你喜欢
  • 2022-12-23
  • 2021-12-16
  • 2021-07-25
  • 2022-01-15
  • 2021-12-03
  • 2021-07-05
相关资源
相似解决方案