Hutool和POI读写excel中遇到的错误,关于POM.xml依赖

使用Hutool和POI读写excel中遇到的错误

报错部分:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Handler dispatch failed; nested exception is java.lang.NoSuchMethodError: org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontsImpl.getXmlObjectArray(Ljavax/xml/namespace/QName;[Lorg/apache/xmlbeans/XmlObject;)[Lorg/apache/xmlbeans/XmlObject;] with root cause
java.lang.NoSuchMethodError: org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontsImpl.getXmlObjectArray(Ljavax/xml/namespace/QName;[Lorg/apache/xmlbeans/XmlObject;)[Lorg/apache/xmlbeans/XmlObject;
at org.openxmlformats.schemas.spreadsheetml.x2006.main.impl.CTFontsImpl.getFontArray(CTFontsImpl.java:71) ~[poi-ooxml-lite-5.0.0.jar:na]

首先一定要明确的一点说,hutool版本和poi版本一定要适配,不然会出现各种各样的问题,比如让你缺失一个包然后导进去一个新的包,然后就又会出现要继续让你添加新的依赖来导入包,那是一定无法解决问题的,在确保你的远端仓库可以支持你频繁变动依赖版本的情况下,多尝试换几个版本。
比如我下方代码展示的两个版本,因为5.几版本的hutool要求poi版本需要在4.1.2或以上其他版本,但也不是鼓励大家乱改版本摸奖式来解决问题,但是笔者之前hutool使用的版本是5.7.20,poi是4.1.2也无法解决问题。所以在能用的前提下,可以参照我一下的版本来添加依赖,希望可以省去很多不必要的麻烦替你省下时间。

<dependency>
            <groupId>cn.hutool</groupId>
            <artifactId>hutool-all</artifactId>
            <version>5.6.6</version>
        </dependency>

        <dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>4.1.2</version>
        </dependency>

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值