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以上即可。如下图:

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM