2013-10-21 119 views
2

我必须导入几个自定义JavaJasperReports的JRXML文件。
我能够做到这一点使用在jrxml中导入自定义类并使用maven插件

<import value="org.ga.jasper.sample.MyCustomClass"/> 

这工作完全正常,我能够运行这个JRXML和测试我的代码。

问题是当我想要通过使用JasperReports的,Maven的插件预编译成.jasper文件,然后这一点。

当做一个构建时,它抱怨说它没有找到我的包,因此导入无效。

package org.ga.jasper.sample does not exist 
import org.ga.jasper.sample.MyCustomClass; 

仅供参考,我的Java代码.jrxml为是相同的行家模块中,但在不同的文件夹中。

以下是我的插件标签的代码

<plugin> 
    <groupId>org.codehaus.mojo</groupId> 
    <artifactId>jasperreports-maven-plugin</artifactId> 
    <executions> 
     <execution> 
      <goals> 
       <goal>compile-reports</goal> 
      </goals> 
     </execution> 
    </executions> 
    <configuration> 
     <sourceDirectory>src/main/resources/jasper</sourceDirectory> 
     <outputDirectory>${project.build.directory}/jasper</outputDirectory> 
     <compiler>net.sf.jasperreports.engine.design.JRJavacCompiler</compiler> 
    </configuration> 
    <dependencies> 
     <dependency> 
      <groupId>net.sf.jasperreports</groupId> 
      <artifactId>jasperreports</artifactId> 
      <version>4.5.1</version> 
     </dependency> 
    </dependencies> 
</plugin> 

回答

1

这是我如何解决这个问题。添加阶段

  <plugin> 
      <groupId>org.codehaus.mojo</groupId> 
      <artifactId>jasperreports-maven-plugin</artifactId> 
      <executions> 
      <execution> 
        <phase>compile</phase> 
        <goals> 
        <goal>compile-reports</goal> 
        </goals> 
      </execution> 
      </executions> 
      <configuration> 
      <sourceDirectory>src/main/resources/jasper</sourceDirectory> 
      <outputDirectory>${project.build.directory}/jasper</outputDirectory> 
       <compiler>net.sf.jasperreports.engine.design.JRJavacCompiler</compiler> 
      </configuration> 
      <dependencies> 
      <dependency> 
      <groupId>net.sf.jasperreports</groupId> 
      <artifactId>jasperreports</artifactId> 
      <version>4.5.1</version> 
      </dependency> 
      </dependencies> 
     </plugin> 
+0

你做了什么,你能解释你更改了哪些配置字段? – katwekibs