目前,对于我正在进行的项目,我使用的是Maven样式的项目。
我使用Maven作为我所有的依赖项。
我的依赖项之一是一个jar文件(ExtentReports)。
我想在这个jar文件中编辑一个XML文件。我怎样才能做到这一点?
我在网上看到过使用ZIP工具的情况,但是当程序重新运行时,它会不会被覆盖,就像我使用Maven一样?还是我对Maven的概念错了?
提前谢谢。
编辑:
<?xml version="1.0" encoding="UTF-8"?>
<extentreports>
<configuration>
<!-- report theme -->
<!-- standard, dark -->
<theme>standard</theme>我想把上面的内容改为
<?xml version="1.0" encoding="UTF-8"?>
<extentreports>
<configuration>
<!-- report theme -->
<!-- standard, dark -->
<theme>dark</theme>发布于 2016-06-03 17:22:22
这不是正确的方法,因为ExtentReports.jar的设置部分是默认的,在运行时覆盖默认设置期间加载的任何其他设置都是默认的。
见此处:http://extentreports.relevantcodes.com/java/#configuration
从上面的链接中复制整个配置块,将其放在XML文件中并放到源代码中。在此之后,只需使用以下方法之一在项目启动时加载XML:
// file location: "C:\HelloWorld\extent-config.xml"
loadConfig(new File("C:\HelloWorld\extent-config.xml"));
// loadConfig(Class clazz, String fileName);
// clazz: com.relevantcodes.extentreports.ExtentReports
// packagePath of clazz: com/relevantcodes/extentreports
// final path: com/relevantcodes/extentreports/extent-config.xml
loadConfig(ExtentReports.class, "extent-config.xml");
// loadConfig(Class clazz, String basePackagePath, String fileName;
// clazz: com.relevantcodes.extentreports.ExtentReports
// packagePath of clazz: com/relevantcodes/extentreports
// basePackagePath: "resources"
// final path: com/relevantcodes/extentreports/resources/extent-config.xml
loadConfig(ExtentReports.class, "resources", "extent-config.xml");https://stackoverflow.com/questions/37610174
复制相似问题