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

问题:

因工作需要,在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】编译错误的解决

 

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

上一篇:VMware Workstaion 安装一台Centos7 服务器之后 复制多台Centos7


下一篇:Ubuntu 连接时显示 There is 1 zombie process.