Eclipse - Jasper 报告未编译 (java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12178615/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 18:53:16  来源:igfitidea点击:

Eclipse - Jasper report not compiling (java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester)

javaeclipsejasper-reports

提问by bstack

I am trying to generate a jasper report via the Eclipse ide, however when I execute the following line of code:

我试图通过 Eclipse ide 生成一个 jasper 报告,但是当我执行以下代码行时:

jasperReport = JasperCompileManager.compileReport("reports/samplereport.jrxml");

I get the following error:

我收到以下错误:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/digester/Digester
    at net.sf.jasperreports.engine.JasperCompileManager.compileReport(JasperCompileManager.java:146)

I have added the apache common digester jar as a project library but it does not seem to make a difference. NOTE: I am from a java novice (i.e. Ive a .NET background,) so I am very likely doing something really obvious!

我已将 apache 通用消化器 jar 添加为项目库,但它似乎没有什么区别。注意:我是 Java 新手(即我有 .NET 背景),所以我很可能会做一些非常明显的事情!

回答by erencan

you may be missing some jars. try to add these ones with any version.

你可能缺少一些罐子。尝试使用任何版本添加这些。

jasperreports-.jar;
jasperreports-javaflow.jar;
commons-beanutils.jar;
commons-collections.jar;
commons-logging.jar;
commons-digester.jar

jasperreports-.jar;
jasperreports-javaflow.jar;
commons-beanutils.jar;
公共集合.jar;
commons-logging.jar;
commons-digester.jar

回答by Goke Obasa

If your project is based on maven, you can add Jasper reports as a maven dependency, see sample code snippet below. Jasper report would automatically import all the libraries it needs to work properly.

如果您的项目基于 maven,您可以将 Jasper 报告添加为 maven 依赖项,请参阅下面的示例代码片段。Jasper 报告会自动导入它正常工作所需的所有库。

...
<dependency>
    <groupId>net.sf.jasperreports</groupId>            
    <artifactId>jasperreports</artifactId>
    <version>6.4.1</version>
</dependency>
...