Maven 2 通过Maven在同一项目中编译具有scriptlet依赖关系的JasperReports jrxml

Maven 2 通过Maven在同一项目中编译具有scriptlet依赖关系的JasperReports jrxml,maven-2,jasper-reports,Maven 2,Jasper Reports,我有一个报告项目,它被编译、打包并包含在战争中。我使用jasperreports maven插件在报表项目中编译jasperreports模板。我有一个循环依赖的问题,其中一个模板在同一个项目中需要一个scriptlet类,但是scriptlet类在报告之前不会被编译,并且在编译过程中会出现ClassNotFound异常。除了声明对先前编译过的jar版本的系统依赖性之外,还有没有其他方法可以在模板之前先编译类或者其他解决方法 这是我的pom: <project xmlns="http://

我有一个报告项目,它被编译、打包并包含在战争中。我使用jasperreports maven插件在报表项目中编译jasperreports模板。我有一个循环依赖的问题,其中一个模板在同一个项目中需要一个scriptlet类,但是scriptlet类在报告之前不会被编译,并且在编译过程中会出现ClassNotFound异常。除了声明对先前编译过的jar版本的系统依赖性之外,还有没有其他方法可以在模板之前先编译类或者其他解决方法

这是我的pom:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<artifactId>report</artifactId>

<name>report</name>
<url>http://maven.apache.org</url>

<properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
    <plugins>
        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
                <execution>
                    <configuration>
                        <artifactItems>
                            <artifactItem>
                                <groupId>net.sf.jasperreports</groupId>
                                <artifactId>jasperreports-fonts</artifactId>
                                <type>jar</type>
                                <overWrite>true</overWrite>
                            </artifactItem>
                            <artifactItem>
                                <groupId>net.sf.jasperreports</groupId>
                                <artifactId>jasperreports</artifactId>
                                <type>jar</type>
                                <overWrite>true</overWrite>
                            </artifactItem>
                            <artifactItem>
                                <groupId>ar.com.fdvs</groupId>
                                <artifactId>DynamicJasper</artifactId>
                                <type>jar</type>
                                <overWrite>true</overWrite>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>jasperreports-maven-plugin</artifactId>
            <executions>
                <execution>
                    <goals>
                        <goal>compile-reports</goal>
                    </goals>
                </execution>
            </executions>
            <configuration>

                <outputDirectory>${project.build.directory}/generated-jasper</outputDirectory>
                <sourceDirectory>src/main/resources/com/example/report/</sourceDirectory>
                <compiler>net.sf.jasperreports.compilers.JRGroovyCompiler</compiler>
            </configuration>

            <dependencies>
                <dependency>
                    <groupId>net.sf.jasperreports</groupId>
                    <artifactId>jasperreports</artifactId>
                    <version>4.0.1</version>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-all</artifactId>
                    <version>1.8.5</version>
                </dependency>
                <dependency>
                    <groupId>log4j</groupId>
                    <artifactId>log4j</artifactId>
                    <version>1.2.16</version>
                </dependency>

                <!-- use this if you have a report dependency at compile time -->
                <!-- 
                <dependency>
                    <groupId>com.example.usedforcompilingjasperreports</groupId>
                    <artifactId>compilejasperreports</artifactId>
                    <scope>system</scope>
                    <version>0.0.1</version>
                    <systemPath>${basedir}/src/main/resources/com/example/report/lib/report-${version}.jar</systemPath>
                </dependency>
                -->
            </dependencies>
        </plugin>
    </plugins>
    <resources>
        <resource>
            <directory>src/main/resources</directory>
        </resource>
    </resources>
    <pluginManagement>
        <plugins>
            <!--This plugin's configuration is used to store Eclipse m2e settings 
                only. It has no influence on the Maven build itself. -->
            <plugin>
                <groupId>org.eclipse.m2e</groupId>
                <artifactId>lifecycle-mapping</artifactId>
                <version>1.0.0</version>
                <configuration>
                    <lifecycleMappingMetadata>
                        <pluginExecutions>
                            <pluginExecution>
                                <pluginExecutionFilter>
                                    <groupId>
                                        org.codehaus.mojo
                                    </groupId>
                                    <artifactId>
                                        jasperreports-maven-plugin
                                    </artifactId>
                                    <versionRange>
                                        [1.0-beta-2,)
                                    </versionRange>
                                    <goals>
                                        <goal>compile-reports</goal>
                                    </goals>
                                </pluginExecutionFilter>
                                <action>
                                    <ignore></ignore>
                                </action>
                            </pluginExecution>
                        </pluginExecutions>
                    </lifecycleMappingMetadata>
                </configuration>
            </plugin>
        </plugins>
    </pluginManagement>
</build>
<dependencies>
    <dependency>
        <groupId>junit</groupId>
        <artifactId>junit</artifactId>
        <version>3.8.1</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-context</artifactId>
        <version>3.0.6.RELEASE</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework</groupId>
        <artifactId>spring-beans</artifactId>
        <version>3.0.6.RELEASE</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>com.example</groupId>
        <artifactId>persistence</artifactId>
        <version>${project.version}</version>
    </dependency>
    <dependency>
        <groupId>log4j</groupId>
        <artifactId>log4j</artifactId>
        <version>1.2.16</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>ar.com.fdvs</groupId>
        <artifactId>DynamicJasper</artifactId>
        <version>3.1.9</version>
    </dependency>
    <dependency>
        <groupId>com.lowagie</groupId>
        <artifactId>itext</artifactId>
        <version>2.1.7</version>
    </dependency>
    <dependency>
        <groupId>net.sf.jasperreports</groupId>
        <artifactId>jasperreports</artifactId>
        <version>4.0.1</version>
    </dependency>
    <dependency>
        <groupId>net.sf.jasperreports</groupId>
        <artifactId>jasperreports-fonts</artifactId>
        <version>4.0.1</version>
    </dependency>
    <dependency>
        <groupId>commons-lang</groupId>
        <artifactId>commons-lang</artifactId>
        <version>2.6</version>
    </dependency>
    <dependency>
        <!-- not used but necessary to avoid an unexpected compiletion exception 
            An exception has occurred in the compiler (1.6.0_04). Please file a bug at 
            the Java Developer Connection (http://java.sun.com/webapps/bugreport) after 
            checking the Bug Parade for duplicates. Include your program and the following 
            diagnostic in your report. Thank you. com.sun.tools.javac.code.Symbol$CompletionFailure: 
            class file for javax.persistence.CascadeType not found -->
        <groupId>org.hibernate</groupId>
        <artifactId>ejb3-persistence</artifactId>
        <version>1.0.1.GA</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>javax.servlet</groupId>
        <artifactId>servlet-api</artifactId>
        <version>2.5</version>
    </dependency>
    <dependency>
        <groupId>javax.faces</groupId>
        <artifactId>jsf-api</artifactId>
        <version>2.1</version>
    </dependency>
    <dependency>
        <groupId>commons-io</groupId>
        <artifactId>commons-io</artifactId>
        <version>2.1</version>
    </dependency>
    <dependency>
        <groupId>org.apache.poi</groupId>
        <artifactId>poi</artifactId>
        <version>3.7</version>
    </dependency>
    <dependency>
        <groupId>jfree</groupId>
        <artifactId>jfreechart</artifactId>
        <version>1.0.12</version>
    </dependency>
    <dependency>
        <groupId>jfree</groupId>
        <artifactId>jcommon</artifactId>
        <version>1.0.15</version>
    </dependency>
    <dependency>
        <groupId>com.force.api</groupId>
        <artifactId>force-wsc</artifactId>
        <version>22.0.0</version>
    </dependency>
    <dependency>
        <groupId>com.sforce.soap</groupId>
        <artifactId>salesforce-webservices</artifactId>
        <version>1.1.0</version>
    </dependency>
</dependencies>
<parent>
    <groupId>com.example</groupId>
    <artifactId>assemble</artifactId>
    <version>2.2.0-SNAPSHOT</version>
    <relativePath>../assemble/pom.xml</relativePath>
</parent>
</project>

4.0.0
报告
报告
http://maven.apache.org
UTF-8
maven依赖插件
net.sf.jasperreports
jasperreports字体
罐子
真的
net.sf.jasperreports
jasperreports
罐子
真的
ar.com.fdvs
动态阿斯珀
罐子
真的
org.codehaus.mojo
jasperreports maven插件
编写报告
${project.build.directory}/generated jasper
src/main/resources/com/example/report/
net.sf.jasperreports.compilers.JRGroovyCompiler
net.sf.jasperreports
jasperreports
4.0.1
org.codehaus.groovy
groovy all
1.8.5
log4j
log4j
1.2.16
src/main/resources
org.eclipse.m2e
生命周期映射
1.0.0
org.codehaus.mojo
jasperreports maven插件
[1.0-beta-2,]
编写报告
朱尼特
朱尼特
3.8.1
测试
org.springframework
spring上下文
3.0.6.1发布
假如
org.springframework
春豆
3.0.6.1发布
假如
com.example
坚持不懈
${project.version}
log4j
log4j
1.2.16
假如
ar.com.fdvs
动态阿斯珀
3.1.9
com.lowagie
文字
2.1.7
net.sf.jasperreports
jasperreports
4.0.1
net.sf.jasperreports
jasperreports字体
4.0.1
公地郎
公地郎
2.6
org.hibernate
ejb3持久性
1.0.1.GA
假如
javax.servlet
servlet api
2.5
javax.faces
JSFAPI
2.1
公地io
公地io
2.1
org.apache.poi
poi
3.7
jfree
柱状图
1.0.12
jfree
共同
1.0.15
com.force.api
强制wsc
22.0.0
com.sforce.soap
salesforce Web服务
1.1.0
com.example
集合
2.2.0-快照
../assemble/pom.xml
谢谢,


Tom

这可能有点晚了,但我认为您可以尝试将jasperreports maven插件的执行绑定到稍后的maven构建阶段

默认情况下,它在生成资源阶段运行,此时java类尚未编译


查看第页代码框下方的段落。

太棒了!太简单了。谢谢您,先生。