วิธีแก้ไข NoClassDefFoundError org / apache / commons / logging / LogFactory [ซ้ำ]
Oct 17 2020
ด้านล่างนี้คือรหัสที่ฉันพยายามใช้เพื่อเชื่อมต่อกับฐานข้อมูลและดูรายงานใน JasperViewer
private void jButton1ActionPerformed(ActionEvent evt) {
try {
String dbURL = "jdbc:oracle:thin:@localhost:1521:xe";
String username = "user";
String password = "pwd";
Connection con = DriverManager.getConnection(dbURL, username, password);
String reportPath = "C:\\path\\extention.jrxml";
JasperReport jr = JasperCompileManager.compileReport(reportPath);
JasperPrint jp = JasperFillManager.fillReport(jr, null, con);
JasperViewer.viewReport(jp);
con.close();
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
ฉันได้รับข้อผิดพลาดต่อไปนี้:
Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/logging/LogFactory
คำตอบ
1 thetechnician94 Oct 17 2020 at 02:39
ฉันไม่รู้มากเกี่ยวกับ Jasper แต่ฉันคิดว่ามันมีการพึ่งพา Apache Commons Log Framework ดังนั้นคุณอาจต้องเพิ่ม Apache Commons Logging ใน classpath ของคุณ
ดู: https://commons.apache.org/proper/commons-logging/guide.html