gpt4 book ai didi

java - NoClassDefFoundError:org/apache/commons/logging/LogFactory

转载 作者:行者123 更新时间:2023-11-29 07:46:18 25 4
gpt4 key购买 nike

我是 JasperReports 的新手,我想将 JasperReports 集成到我的 Java 程序中,所以当我点击打印按钮时,程序会显示报告。但是当我点击按钮时,我得到了一个NoClassDefFoundError

代码

JButton btnReport= new JButton("Report");
btnReport.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
try{
String fileName= "src/learnReport/Leaf_Grey.jasper";
Connection con = connect.getConnect();
File file = new File(NameFile);
JasperReport jasperReport = (JasperReport) JRLoader.loadObject(file);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null,con);
JasperViewer.viewReport(jasperPrint,false);
} catch(Exception ex){
System.out.println(ex);
}
}
});

运行时错误

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
at net.sf.jasperreports.engine.util.JRLoader.<clinit>(JRLoader.java:81)
at learnReport.Learning$6.actionPerformed(Learning.java:195)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)

最佳答案

您错过了 jar 文件“org-apache-commons-logging.jar”。将这个 jar 加载到您的项目中。问题将得到解决。

关于java - NoClassDefFoundError:org/apache/commons/logging/LogFactory,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25376089/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com