2017-04-25 82 views
1

我有點新的碧玉報告,我想打電話給我已經創建和編輯了的.jrxml但我越來越想讀的.jrxml Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/codehaus/groovy/control/CompilationFailedExceptionJasper報表導出PDF的Java

當此記錄

這裏是我的代碼:

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()); 
    } 
} 
+2

你的項目需要另一種依賴......檢查[這裏](HTTP:/ /stackoverflow.com/questions/11 773702/why-do-i-get-exception-java-lang-noclassdeffounderror-org-codehaus-groovy) – Dazak

+0

可愛的,這工作如此順利。 –

回答

1

我使用maven,所以加入常規的依賴關係所做的伎倆

<dependency> 
    <groupId>org.codehaus.groovy</groupId> 
    <artifactId>groovy-all</artifactId> 
    <version>2.4.10</version> 
</dependency>