jasper-reports
JasperReports .jrxmlを.jasperにコンパイルする
サーチ…
IDE(統合開発環境)
IDE Jaspersoft Studio ( JSS )または古いバージョンのiReport Designerでは、 プレビューを押すだけで十分です。
JasperReportsのデザインファイル.jrxml自動的にコンパイルされます.jasperと同じフォルダに.jrxml エラーが存在しない場合。
別の方法は、 JSSの 「レポートのコンパイル」ボタンを押すことです
iReportの レポートインスペクタから呼び出されたコンテキストメニュー「コンパイルレポート」を使用します
Apache Antで
<target name="compile" description="Compiles report designs specified using the 'srcdir' in the <jrc> tag." depends="prepare-compile-classpath">
<mkdir dir="./build/reports"/>
<taskdef name="jrc" classname="net.sf.jasperreports.ant.JRAntCompileTask">
<classpath refid="project-classpath"/>
</taskdef>
<jrc
srcdir="./reports"
destdir="./build/reports"
tempdir="./build/reports"
keepjava="true"
xmlvalidation="true">
<classpath refid="sample-classpath"/>
<include name="**/*.jrxml"/>
</jrc>
</target>
Apache Antビルド・ツールをシステムに正しくインストールする必要がある
Javaで
それはコンパイルすることは可能ですが.jrxmlにファイルを.jasper Javaコードを使用してファイル、これが最良の事前コンパイルすることによって回避され、パフォーマンスヒット招き.jrxml IDEを使用してファイルを。これを念頭において、 .jrxmlファイルをコンパイルするには、 JasperCompileManagerを次のように使用します。
JasperCompileManager.compileReportToFile(
"designFile.jrxml", //Relative or absoulte path to the .jrxml file to compile
"compiled.jasper"); //Relative or absolute path to the compiled file .jasper
Apache Mavenの場合
Alex NederlofによるJasperReports-pluginは、放棄されたorg.codehaus.mojo:jasperreports-maven-pluginプラグインの良い代替手段です。
プラグインの追加は典型的な簡単な手順です:
<build>
<plugins>
<plugin>
<groupId>com.alexnederlof</groupId>
<artifactId>jasperreports-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<phase>process-sources</phase>
<goals>
<goal>jasper</goal>
</goals>
</execution>
</executions>
<configuration>
<sourceDirectory>src/main/resources/jrxml</sourceDirectory>
<outputDirectory>${project.build.directory}/jasper</outputDirectory>
</configuration>
</plugin>
</plugins>
</build>
Mavenでのコンパイルのコマンド:
mvn jasperreports:jasper
ジャスパーファイルは、 $ {project.build.directory} / jasperフォルダー(例えば、 / target / jasper内 )に作成されます。
Modified text is an extract of the original Stack Overflow Documentation
ライセンスを受けた CC BY-SA 3.0
所属していない Stack Overflow

