You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用JodConverter时unoloader.jar路径匹配异常问题求助

LibreOffice与JODConverter依赖路径异常问题解决

问题描述

已安装默认路径C:\Program Files\LibreOffice的LibreOffice 7.6,添加以下Maven依赖:

<dependency>
    <groupId>org.jodconverter</groupId>
    <artifactId>jodconverter-local-lo</artifactId>
    <version>4.4.6</version>
</dependency>
<dependency>
    <groupId>org.libreoffice</groupId>
    <artifactId>unoloader</artifactId>
    <version>7.4.1</version>
</dependency>

运行程序时抛出java.io.FileNotFoundException,提示找不到路径C:\Users\***\.m2\repository\org\libreoffice\libreoffice\7.4.1\unoloader.jar,但unoloader.jar实际存储路径为C:\Users\***\.m2\repository\org\libreoffice\unoloader\7.4.1\unoloader.jar。手动复制文件到报错路径后程序可正常运行,但添加jodconverter-core依赖无法解决问题。

解决方法

1. 修正Maven依赖坐标

jodconverter-local-lo依赖的是org.libreoffice:libreoffice这个完整artifact,而非单独的unoloader,所以替换现有依赖为:

<dependency>
    <groupId>org.jodconverter</groupId>
    <artifactId>jodconverter-local-lo</artifactId>
    <version>4.4.6</version>
</dependency>
<dependency>
    <groupId>org.libreoffice</groupId>
    <artifactId>libreoffice</artifactId>
    <version>7.4.1</version>
    <type>pom</type>
</dependency>

该依赖会自动拉取包括unoloader.jar在内的相关组件,并放置到程序期望的路径下。

2. 指定本地LibreOffice安装路径(推荐)

跳过Maven仓库的依赖查找,直接配置程序使用本地已安装的LibreOffice,彻底规避路径匹配问题。代码中添加配置:

// 创建本地LibreOffice配置
LocalOfficeManagerConfig config = new LocalOfficeManagerConfig();
config.setOfficeHome("C:\\Program Files\\LibreOffice");
// 初始化并启动OfficeManager
OfficeManager officeManager = LocalOfficeManager.make(config);
officeManager.start();

3. 版本替换兼容方案

通过版本对齐解决问题,需保证JODConverter、LibreOffice依赖与本地安装版本兼容:

  • 本地LibreOffice为7.6,可升级JODConverter到4.5.x版本(适配LibreOffice 7.6),同时匹配对应版本的LibreOffice依赖:
<dependency>
    <groupId>org.jodconverter</groupId>
    <artifactId>jodconverter-local-lo</artifactId>
    <version>4.5.0</version>
</dependency>
<dependency>
    <groupId>org.libreoffice</groupId>
    <artifactId>libreoffice</artifactId>
    <version>7.6.0</version>
    <type>pom</type>
</dependency>

注意:版本升级前需确认JODConverter与LibreOffice的官方兼容矩阵,避免新的兼容性问题。

内容的提问来源于stack exchange,提问作者LALA

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.11 12:02:32