수색…


IDE (통합 개발 환경)

IDE Jaspersoft Studio ( JSS ) 나 이전 버전의 iReport Designer 에서는 미리보기 를 누르면 충분합니다.

은 JasperReports 디자인 파일 .jrxml 자동으로 컴파일됩니다 .jasper 과 동일한 폴더에 .jrxml 오류가 존재하지 않는 경우.

또 다른 방법은 JSS 에서 "보고서 컴파일" 버튼을 누르는 것입니다.

JSS를 통해 컴파일

또는 iReport의 보고서 속성 에서 호출 된 상황에 맞는 메뉴 "보고서 컴파일"을 사용하십시오

iReport를 통해 컴파일

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 빌드 도구가 시스템에 올바르게 설치되어야합니다.

Java 사용

.jasper 파일을 Java 코드를 사용하여 .jrxml 파일로 컴파일 할 수는 있지만 IDE를 사용하여 .jrxml 파일을 미리 컴파일하면 성능이 저하되지 .jrxml . 이를 염두에두고 다음과 같이 JasperCompileManager 를 사용하여 .jrxml 파일을 컴파일 할 수 있습니다.

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 NederlofJasperReports-plugin 은 버려진 org.codehaus.mojo : jasperreports-maven-plugin 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

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