简体   繁体   English

Docx4j 考虑使用 Xerces 警告

[英]Docx4j consider using Xerces Warning

In a Spring MVC server I have this warning every time I use docx4j to generate a docx.在 Spring MVC 服务器中,每次使用 docx4j 生成 docx 时都会收到此警告。 The server functions well, but I have a huge log with this warning服务器运行良好,但我有一个带有此警告的巨大日志

2022-04-27 18:00:46.241 [http-nio-8080-exec-3] WARN  org.docx4j.XmlUtils - default SAXParserFactory property : null
 Please consider using Xerces.
2022-04-27 18:00:46.248 [http-nio-8080-exec-3] WARN  org.docx4j.XmlUtils - default DocumentBuilderFactory property: null
 Please consider using Xerces.

My pom.xml is:我的 pom.xml 是:

<!-- Doc4j -->
<dependency>
    <groupId>org.docx4j</groupId>
    <artifactId>docx4j-JAXB-ReferenceImpl</artifactId>
    <version>8.3.4</version>
</dependency>
<dependency>
      <groupId>org.docx4j</groupId>
      <artifactId>docx4j-core</artifactId>
      <version>8.3.4</version>
</dependency>
<dependency>
    <groupId>org.docx4j</groupId>
    <artifactId>docx4j-export-fo</artifactId>
    <version>8.3.4</version>
</dependency>
<dependency>
    <groupId>xerces</groupId>
    <artifactId>xercesImpl</artifactId>
    <version>2.12.2</version>
</dependency>

What am I missing?我错过了什么?

If you get ... [main] WARN org.docx4j.XmlUtils - default SAXParserFactory property : null Please consider using Xerces.如果您得到... [main] WARN org.docx4j.XmlUtils - 默认 SAXParserFactory 属性:null 请考虑使用 Xerces。 [main] WARN org.docx4j.XmlUtils - default DocumentBuilderFactory property: null Please consider using Xerces. [main] WARN org.docx4j.XmlUtils - 默认 DocumentBuilderFactory 属性:null 请考虑使用 Xerces。

... you need xerces on the CP and you need to set the property in docx4j.properties for sax parser to xerces ...您需要在 CP 上执行 xerces,并且您需要在 docx4j.properties 中将 sax 解析器的属性设置为 xerces

From docx4j.properties [JAXP factories] section uncomment ... [javax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl] *** NOTE you will have a different package name for SaxParserFactoryImpl based on the version of xerces从 docx4j.properties [JAXP factory] ​​部分取消注释 ... [javax.xml.parsers.SAXParserFactory=com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl] *** 注意您将有不同的包名称SaxParserFactoryImpl 基于 xerces 的版本

The version of docx4j will have the dependencies needed to be on the CP in /dependencies docx4j 的版本将具有需要在 /dependencies 中的 CP 上的依赖项

if you get ... [main] WARN org.docx4j.utils.ResourceUtils - Couldn't get resource: docx4j.properties [main] WARN org.docx4j.Docx4jProperties - Couldn't find/read docx4j.properties;如果你得到... [main] WARN org.docx4j.utils.ResourceUtils - 无法获取资源:docx4j.properties [main] WARN org.docx4j.Docx4jProperties - 找不到/读取 docx4j.properties; docx4j.properties not found via classloader.通过类加载器找不到 docx4j.properties。

... you have not deployed docx4j.properties - docx4j has defaults, so you first need to deploy docx4j.properties before you can affect those defaults ...您尚未部署 docx4j.properties - docx4j 具有默认值,因此您首先需要部署 docx4j.properties 才能影响这些默认值

you need to create (or copy from source ~/resources/) [docx4j.properties]您需要创建(或从源 ~/resources/ 复制)[docx4j.properties]

org.docx4j.Docx4jProperties.java loads docx4j.properties on init() to overwrite the defaults org.docx4j.Docx4jProperties.java 在 init() 上加载 docx4j.properties 以覆盖默认值

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM