范围报告例外

时间:2019-02-19 13:59:36

标签: selenium-webdriver report extent

使用范围报告时出现以下异常。 任何线索我该如何解决? 我已经列出了我使用的来自POM.XML的依赖项

java.lang.NoClassDefFoundError: freemarker/template/TemplateModelException
at com.relevantcodes.extentreports.ExtentReports.<init>(ExtentReports.java:86)
 at com.relevantcodes.extentreports.ExtentReports.<init>(ExtentReports.java:375)
 at com.eshot.qa.utils.ExtentReporterNG.generateReport(ExtentReporterNG.java:29)
 at org.testng.TestNG.generateReports(TestNG.java:1097)
 at org.testng.TestNG.run(TestNG.java:1022)
 at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:114)
 at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
 at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)
Caused by: java.lang.ClassNotFoundException: freemarker.template.TemplateModelException
 at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:357)

我在POM.xml文件中具有以下依赖项

<dependency>
    <groupId>com.relevantcodes</groupId>
    <artifactId>extentreports</artifactId>
    <version>2.41.2</version>
</dependency>

<dependency>
    <groupId>org.freemarker</groupId>
    <artifactId>freemarker</artifactId>
    <version>2.3.23</version>
</dependency>

<dependency>
    <groupId>org.jsoup</groupId>
    <artifactId>jsoup</artifactId>
    <version>1.8.3</version>
</dependency>

<dependency>
    <groupId>org.xerial</groupId>
    <artifactId>sqlite-jdbc</artifactId>
    <version>3.8.11.1</version>
</dependency>

<dependency>
    <groupId>org.mongodb</groupId>
    <artifactId>mongodb-driver</artifactId>
    <version>3.0.4</version>
</dependency>

2 个答案:

答案 0 :(得分:1)

我建议使用最新版本,而不是不再支持的版本2。

<!-- https://mvnrepository.com/artifact/com.aventstack/extentreports -->
<dependency>
    <groupId>com.aventstack</groupId>
    <artifactId>extentreports</artifactId>
    <version>4.0.9</version>
</dependency>

以下是最新文档的链接:http://extentreports.com/docs/versions/4/java/

答案 1 :(得分:0)

If you have added freemarker and extentreports lib and still facing above error  

那么您应该按照以下步骤操作,它将正常运行
1)从本地存储库中仅删除“ freemarker”文件夹
即.m2 \ repository \ org \ freemarker \
2)并再次保存您的pom.xml文件并运行代码