问题
When using the jasperreports-maven-plugin/1.0-beta-2 to compile a jrxml file to jasper, the resulting report doesn't display unicode characters properly, it displays ???? instead.
It is obvious this is a font problem. So I opened iReport 4.0.1, and compiled the jrxml file from there without changing any specific settings, the resulting jasper file could display the unicode characters just fine. So I am assuming there are some compile time properties which I am not setting properly.
I thought of using the tag of the jasperreports-maven-plugin plugin, to define the resulting encoding properties to the used when compiling the jasper file. But I couldnt find what properties to set there.
I guessed some properties from
The JasperReport Configuration Reference
specifically
net.sf.jasperreports.default.pdf.encoding
net.sf.jasperreports.export.character.encoding
but to no avail.
So I would like to know either if iReport uses some special compilation options regarding fonts,encoding or charset properties that can be set in the asperreports-maven-plugin mojo.
Alernatively, if this is not possible from this mojo.
Thanks
回答1:
The Maven plugin is most likely not using JasperReports 4.0.1 to compile the report. By default it uses the JasperReports defined as a dependency: jasperreports:jasperreports:1.2.0.
Because JasperReports 4.0.1 has a different group, artifact and version this dependency can't be overridden. Exclusions only work for dependencies of dependencies, so that isn't an option either. You will need a different version of the mojo to compile templates using 4.0.1.
Lucky for you a patch has already been applied to the trunk of the mojo so all you have to do is check out the code and deploy a version to your repository.
http://svn.codehaus.org/mojo/trunk/mojo/jasperreports-maven-plugin/
After deploying the plugin you will need to override the dependency to 4.0.1. You do this by defining dependencies at the plugin level.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>jasperreports-maven-plugin</artifactId>
<dependencies>
<dependency>
<groupId>net.sf.jasperreports</groupId>
<artifactId>jasperreports</artifactId>
<version>4.0.1</version>
</dependency>
</dependencies>
</plugin>
来源:https://stackoverflow.com/questions/5369784/maven-jasperreports-maven-plugin-define-compile-charset