簡體   English   中英

使用 maven 插件生成 .jasper

[英]Generate .jasper with maven plugin

我希望提高我的應用程序的性能,它有兩種類型的報告,然后在執行時編譯,如下所示:

  final JasperDesign design = JRXmlLoader.load(input);

  final JasperReport compiledReport = JasperCompileManager.compileReport(design);

每當用戶想要查看應用程序上的報告時,都會執行此代碼。 為了避免這種情況,我試圖通過 maven jasperreports 插件執行 .jrxml 的編譯,但它不起作用,並且控制台上沒有錯誤。 .jasper 文件沒有出現在我的目錄“outputDirectory”中。

        <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>jasperreports-maven-plugin</artifactId>
        <executions>
         <execution>
              <phase>compile</phase>
            <inherited>false</inherited>
            <goals>
                <goal>compile-reports</goal>
            </goals>
         </execution>
        </executions>
        <configuration>
         <sourceDirectory>src/main/resources/reports</sourceDirectory>
        <outputDirectory>src/main/resources/reports/jasper</outputDirectory>
            <compiler>net.sf.jasperreports.engine.design.JRJdtCompiler</compiler>
        </configuration>
    </plugin>

我知道這是舊的,但是當我在 POM 的<pluginManagement>部分而不是在<plugins>定義插件時,這發生在我身上。

這是我使用的 pom 配置

<build>
    <plugins>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jasperreports-maven-plugin</artifactId>
            <version>1.0-beta-2</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compile-reports</goal>
                    </goals>
                    <configuration>
                        <!--  jrxml file  directory-->
                        <sourceDirectory>src\\main\\resources\\reports\\template</sourceDirectory>
                        <sourceFileExt>.jrxml</sourceFileExt>
                        <compiler>net.sf.jasperreports.engine.design.JRJavacCompiler</compiler>
                        <!--  Destination for jasper file -->
                        <outputDirectory>src\\main\\resources\\reports\\jasper</outputDirectory>
                    </configuration>
                </execution>
            </executions>
            <dependencies>
                <!-- These plugins are used to specify correct version for jrxml xml validation -->
                <dependency>
                    <groupId>net.sf.jasperreports</groupId>
                    <artifactId>jasperreports</artifactId>
                    <version>4.5.0</version>
                </dependency>

                <dependency>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                    <version>1.2.16</version>
                </dependency>

            </dependencies>
        </plugin>

    </plugins>
</build>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM