gpt4 book ai didi

java - 线程 "AWT-EventQueue-0"java.lang.NoClassDefFoundError : org/apache/commons/lang3/Validate 中出现异常

转载 作者:行者123 更新时间:2023-12-01 12:46:30 25 4
gpt4 key购买 nike

我正在尝试使用以下代码获取动态报告:

import java.sql.Connection;
import net.sf.dynamicreports.jasper.builder.JasperReportBuilder;
import net.sf.dynamicreports.report.builder.DynamicReports;
import net.sf.dynamicreports.report.builder.column.Columns;
import net.sf.dynamicreports.report.builder.component.Components;
import net.sf.dynamicreports.report.builder.datatype.DataTypes;
import net.sf.dynamicreports.report.constant.HorizontalAlignment;
import net.sf.dynamicreports.report.exception.DRException;
/**
*
* @author Nigel Backhurst
*/
public class UnsoldLots
{
private Connection con;
private Seller seller;
private int auctionID;

public UnsoldLots(Connection c, Seller s, int a)
{
con = c;
seller = s;
auctionID = a;
String sellerName = seller.FirstName + " " + seller.Surname;
String sellerID = seller.idSeller;
String auction = Integer.toString(a);
String sql = "SELECT LotNumber, Description FROM lots WHERE "
+ "AuctionID = \'" + auction + "\' AND idSellers = \'"
+ sellerID + "\' AND LotSold = \'F\'";
String rTitle = "Unsold Lots for " + sellerName;
JasperReportBuilder report = DynamicReports.report();
//create a new report
report
.columns(
Columns.column("Lot", "LotNumber", DataTypes.integerType()),
Columns.column("Description", "Description", DataTypes.stringType())
)
.title(
//title of the report
Components.text(rTitle )
.setHorizontalAlignment(HorizontalAlignment.CENTER))
.pageFooter(Components.pageXofY())
.setDataSource( sql , con);
try
{
//show the report
report.show();
} catch (DRException e)
{
e.printStackTrace();
}


}
}

但是,当我运行代码时出现以下异常,并且无法找出原因:

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/apache/commons/lang3/Validate
at net.sf.dynamicreports.report.base.component.DRList.setType(DRList.java:80)
at net.sf.dynamicreports.report.base.component.DRList.<init>(DRList.java:52)
at net.sf.dynamicreports.report.base.DRBand.<init>(DRBand.java:44)
at net.sf.dynamicreports.report.base.DRReport.init(DRReport.java:144)
at net.sf.dynamicreports.report.base.DRReport.<init>(DRReport.java:126)
at net.sf.dynamicreports.report.builder.ReportBuilder.<init>(ReportBuilder.java:75)
at net.sf.dynamicreports.jasper.builder.JasperReportBuilder.<init>(JasperReportBuilder.java:117)
at net.sf.dynamicreports.report.builder.DynamicReports.report(DynamicReports.java:120)
at iea.auction.manager.UnsoldLots.<init>(UnsoldLots.java:45)

我怀疑我可能缺少一个包含项,但无法确定是哪个。

最佳答案

您错过了类路径中的commons-lang3.jar。下载并将其添加到您的类路径中。

关于java - 线程 "AWT-EventQueue-0"java.lang.NoClassDefFoundError : org/apache/commons/lang3/Validate 中出现异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24651646/

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