Sök…


Med IDE (Integrerad utvecklingsmiljö)

I IDE Jaspersoft Studio ( JSS ) eller i den äldre versionen iReport Designer räcker det att trycka på Förhandsgranska .

JasperReports designfil .jrxml kommer automatiskt att sammanställas till .jasper i samma mapp som .jrxml om inga fel finns.

Ett annat sätt är att trycka på "Compile Report" -knappen i JSS

Kompilera via JSS

eller använd snabbmenyn "Kompilera Report" anropas från Report Granskare i iReport

Kompilera via iReport

Med Apache Ant

<target name="compile" description="Compiles report designs specified using the 'srcdir' in the &lt;jrc&gt; 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 build-verktyg måste vara korrekt installerat på ditt system

Med Java

Även om det är möjligt att sammanställa .jrxml filer till .jasper filer med Java-kod, medför detta en prestandahit som bäst undviks genom att för-kompilera .jrxml filer med hjälp av IDE. Med det i åtanke kan kompilering av .jrxml filer utföras med JasperCompileManager enligt följande:

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

Med Apache Maven

JasperReports-plugin av Alex Nederlof är ett bra alternativ till övergivna org.codehaus.mojo: jasperreports-maven-plugin plugin.

Att lägga till plugin är en typisk, enkel procedur:

<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>

Kommandot för sammanställning med Maven :

mvn jasperrapporter: jasper

Jasperfilerna skapas i $ {project.build.directory} / jasper- mappen (till exempel i / target / jasper )



Modified text is an extract of the original Stack Overflow Documentation
Licensierat under CC BY-SA 3.0
Inte anslutet till Stack Overflow