我对jasper报告有点新见,我试图调用我已创建和编译的.jrxml但是在尝试阅读.jrxml Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedException
时我得到了这条记录
这是我的代码:
private void saveAsMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
JasperPrint jp;
JasperReport jr;
try {
Connection con=DriverManager.getConnection("jdbc:derby://localhost:1527/Database", "user", "password");
jr=JasperCompileManager.compileReport("Reports/Cierre de Caja.jrxml");
jp=JasperFillManager.fillReport("Reports/Cierre de Caja.jasper", new HashMap(), con);
System.out.println("got jasper");
JasperViewer jv=new JasperViewer(jp);
jv.setVisible(true);
}
catch (JRException e){
System.out.println("Jasper: "+e.getLocalizedMessage());
}
catch (SQLException e){
System.out.println("SQL: "+e.getLocalizedMessage());
}
}
答案 0 :(得分:1)
我正在使用maven,所以添加groovy作为依赖使得这个技巧
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-all</artifactId>
<version>2.4.10</version>
</dependency>