0

我在通过 pom.xml 将 .jrxml 编译为 .jasper 时遇到问题。在给出 mvn clean install、mvn -e compile、mvn eclipse:eclipse 之后,我无法生成 .jasper。下面是我的 pom.xml。我确定我错过了一些东西,但不确定是什么。请帮忙..谢谢提前:) net.sf.jasperreports 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>
4

2 回答 2

2

这是对我有用的片段

        <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>
于 2013-02-06T19:02:24.727 回答
0

我在 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");

于 2013-02-07T19:38:07.847 回答