【问题标题】:JaperReport maven Pom.xml Not creating.jasper fileJaperReport maven Pom.xml 没有创建.jasper 文件
【发布时间】:2013-02-08 03:38:07
【问题描述】:

我在通过 pom.xml 将 .jrxml 编译为 .jasper 时遇到问题。在给出 mvn clean install、mvn -e compile、mvn eclipse:eclipse 之后,我无法生成 .jasper。下面是我的 pom.xml。我确定我错过了一些东西,但不确定是什么。请帮助..谢谢是提前:) 网络.sf.jasperreports 碧玉报告 4.8.0

<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.8.0</version>
                    </dependency>
                 </dependencies>
            </plugin>
        </plugins>

      </build>

    </profile>
  </profiles>

【问题讨论】:

  • 你试过jasperreports:compile-reports如plugin documentation所示吗?
  • 严重:第 2 行第 439 列解析错误:文档根元素“jasperReport”,必须匹配 DOCTYPE 根“null”。 org.xml.sax.SAXParseException;行号:2;列号:439; , 必须匹配 DOCTYPE r t "null"。

标签: java maven jasper-reports


【解决方案1】:

这是适合我的 sn-p

        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jasperreports-maven-plugin</artifactId>
            <version>1.0-beta-2</version>
            <configuration>
                <sourceDirectory>src/main/webapp/WEB-INF/reports</sourceDirectory>
                <outputDirectory>src/main/webapp/WEB-INF/reports</outputDirectory>
            </configuration>
            <executions>
                <execution>
                    <phase>compile</phase>
                    <goals>
                        <goal>compile-reports</goal>
                    </goals>
                </execution>
            </executions>
            <dependencies>
                <dependency>
                    <groupId>jasperreports</groupId>
                    <artifactId>jasperreports</artifactId>
                    <version>3.5.3</version>
                </dependency>
                <dependency>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                    <version>1.2.16</version>
                </dependency>
            </dependencies>
        </plugin>

【讨论】:

  • 感谢 MrsTang 和 Dreamer 都尝试了它确实到达了我的 jrxml,但抱怨严重:第 2 行第 439 列的解析错误:文档根元素“jasperReport”,必须匹配 DOCTYPE 根“null”。 org.xml.sax.SAXParseException;行号:2;列号:439; , 必须匹配 DOCTYPE r t "null"。
  • @user2047899 在这种情况下它应该是由版本冲突引起的。创建 jrxml 的 iReport/Jasper jar lib 版本可能与您在 pom 中提供的版本不匹配。
  • @user2047899 请注意,jasper 报告依赖项在您的 pom 中应该是唯一的,这意味着您的 pom 中可能有多个版本的 jasper 报告依赖项,就像您的 jasper 库中的多个版本一样类路径。
  • 当我给出 jasperreports:compile-reports 命令时,它正在使用 1.2.0 的 jasper 报告 jar,我使用的是 4.8.0,而我的 jrxml 是由 4.8.0 创建的
  • @user2047899 好吧,听起来您已经发现编译报告的版本与 iReport 用于生成 jrxml 的版本不完全匹配,那么该错误不会加倍。
【解决方案2】:

我在 src\main\jasper 中创建了 .jasper -----不是直接在 src\main 中的资源。 现在我无法阅读 java 代码。它总是返回 null。请帮忙。我试过了:

1) 文件 file = new File(ReportConnection.class.getClassLoader().getResource("src/main/jasperreports/sample_Report.jasper").toString());

2)URL 资源 = ClassLoader.getSystemResource("src/main/jasperreports/sample_Report.jasper");

3) FILE_BASE_FOLDER_ON_CLASSPATH = "src//main//jasperreports"; iStream = ReportConnection.class .getClassLoader() .getResourceAsStream( FILE_BASE_FOLDER_ON_CLASSPATH + "sample.jasper");

【讨论】:

    猜你喜欢
    • 2014-02-06
    • 2023-03-14
    • 2022-07-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-04-19
    • 2012-07-24
    • 1970-01-01
    相关资源
    最近更新 更多