如何在jrxml文件中使用lambda表达式? [英] How to use lambda expression in jrxml file?

查看:394
本文介绍了如何在jrxml文件中使用lambda表达式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 jrxml 文件中使用lambda表达式来获取我的字段的值。

I am trying to use lambda expression inside jrxml file to get values for my field.

我导入了相应的类,但它给了我错误

I imported appropriate classes but it is giving me error that


p不能解析为变量。

p cannot be resolved to a variable.

如何在 JasperReports 的模板中使用lambda表达式? / p>

How to use a lambda expression inside JasperReports's templates?.

<textFieldExpression>
    <![CDATA[StringUtils.join(((Collection<Property>)((Object2)$F{field1}.getPropertyValue("property1")).getPropertyValue("property2")).stream().map(p->((Object1)p.getValue()).getName()).collect(toList()),',');]]>
</textFieldExpression>

例外:

net.sf.jasperreports.engine.JRException: Errors were encountered when compiling report expressions class file:
1. p cannot be resolved to a variable


推荐答案

如果你正在使用Eclipse JDT编译器,首先要确保你有一个相当新的版本。

If you're using the Eclipse JDT compiler, first make sure that you have a fairly recent version.

你可以从 Maven ,然后将以下属性添加到jasperreports.properties文件中:

You can get 4.5.1 from Maven for instance, then add the following properties to your jasperreports.properties file:

org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.source=1.8

这篇关于如何在jrxml文件中使用lambda表达式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆