这里写目录标题
- 版本依赖找不到
- XHTMLImporterImpl 缺少,这边已经引用了 docx4j或者docx4j-cored的最新版本依旧缺少
- 如果发生类文件错误,请降低版本
- xhtmlrender相关环境缺失
- Can't instantiate JAXB Reference Implementation
- org/docx4j/jaxb/ri/NamespacePrefixMapper has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
- 最终引用到的所有依赖
- 案例
最近来个需求,复杂的word样式。这边采用的是docx4j 结合Thymeleaf。寻求chatGPT快速使用引发了一些问题。
版本缺少,XHTMLImporterImpl缺失
版本依赖找不到
org.docx4j:docx4j:jar:8.1.5 was not found in http://mirrors.cloud.tencent.com/nexus/repository/maven-public/ during a previous attempt. This failure was cached in the local repository and resolution is not reattempted until the update interval of tencent-cloud has elapsed or updates are forced
解决方法
在mvnrepository 中搜索版本信息,一般各大源的版本都同步的,发现最高只到6.1x
还在仓库中发现,库迁移,那这边直接引入
Relocated → org.docx4j » docx4j-core
XHTMLImporterImpl 缺少,这边已经引用了 docx4j或者docx4j-cored的最新版本依旧缺少
依旧搜索GPT,答案一致,依旧网上冲浪
解决方法
偶然才中央仓库中看到这个依赖
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-ImportXHTML</artifactId>
<version>11.4.8</version>
</dependency>
成功导入
如果发生类文件错误,请降低版本
docx4j-ImportXHTML 11.4.8采用jdk11的,引用的是jd8的
解决方案
<dependency>
<groupId>org.docx4j</groupId>
<artifactId>docx4j-ImportXHTML</artifactId>
<version>8.3.11</version>
</dependency>
xhtmlrender相关环境缺失
导出的时候如果发生xhtmlrender缺失,请加入以下依赖
<dependency>
<groupId>org.docx4j</groupId