首页 > 其他分享 >POI升级5.2.2报错问题

POI升级5.2.2报错问题

时间:2024-03-24 10:33:13浏览次数:29  
标签:5.2 java poi 报错 POI apache org log4j PackageRelationshipCollection

POI升级5.2.2报错问题

标签:版本冲突

报错信息

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.logging.log4j.Logger.atDebug()Lorg/apache/logging/log4j/LogBuilder;
	at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.parseRelationshipsPart(PackageRelationshipCollection.java:309)
	at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.<init>(PackageRelationshipCollection.java:160)
	at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.<init>(PackageRelationshipCollection.java:130)
	at org.apache.poi.openxml4j.opc.PackagePart.loadRelationships(PackagePart.java:565)
	at org.apache.poi.openxml4j.opc.OPCPackage.getParts(OPCPackage.java:745)
	at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:315)
	at org.apache.poi.ooxml.util.PackageHelper.open(PackageHelper.java:59)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:304)
	at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:300)
	at com.lxw.mutils.ExcelUtil.excel2List(ExcelUtil.java:59)
	at com.lxw.mutils.ExcelUtil.excel2List(ExcelUtil.java:36)
	at cn.enn.smart.controller.WorkbenchMonitorGuidelineController.main(WorkbenchMonitorGuidelineController.java:39)

错误代码

org.apache.poi.openxml4j.opc.PackageRelationshipCollection#parseRelationshipsPart,也就是错误信息中所提到的at org.apache.poi.openxml4j.opc.PackageRelationshipCollection.parseRelationshipsPart(PackageRelationshipCollection.java:309)

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
private static final Logger LOG = LogManager.getLogger(PackageRelationshipCollection.class); 
public void parseRelationshipsPart(PackagePart relPart){
 	  ...
      LOG.atDebug().log("Parsing relationship: {}", relPart.getPartName());
      ...
 }

只需要有2.17.1的log4j-api就可以,然而springboot中引入的是2.12.1

image-20240125085830858

image-20240125090006219

网上给出的方案

<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-to-slf4j</artifactId>
    <version>2.17.2</version>
    <exclusions>
        <exclusion>
            <artifactId>slf4j-api</artifactId>
            <groupId>org.slf4j</groupId>
        </exclusion>
        <exclusion>
            <artifactId>log4j-api</artifactId>
            <groupId>org.apache.logging.log4j</groupId>
        </exclusion>
    </exclusions>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.logging.log4j/log4j-api -->
<dependency>
    <groupId>org.apache.logging.log4j</groupId>
    <artifactId>log4j-api</artifactId>
    <version>2.17.2</version>
</dependency>

image-20240125090954354

通过log4j-to-slf4j:2.17.2引入的是log4j-api:2.12.1,所以排除掉,单独引入log4j-api:2.17.2

为啥拍排除org.slf4j也没做解释

标签:5.2,java,poi,报错,POI,apache,org,log4j,PackageRelationshipCollection
From: https://blog.csdn.net/weixin_41883161/article/details/136504624

相关文章

  • PointNet++论文复现(二)【最远点采样-球查询-采样和分组 代码详解】
    最远点采样-球查询-采样和分组-代码详解专栏持续更新中!关注博主查看后续部分!最远点采样、球查询等位于pointnet2_utils.py定义点云坐标归一化点云坐标归一化是一种预处理步骤,用于将点云数据标准化到一个统一的尺度,通常是在一个特定的范围内,比如[-1,1]或[0,1]。这一......
  • PointNet++论文复现(一)【PontNet网络模型代码详解 - 分类部分】
    PontNet网络模型代码详解-分类部分专栏持续更新中!关注博主查看后续部分!分类模型的训练:##e.g.,pointnet2_ssgwithoutnormalfeaturespythontrain_classification.py--modelpointnet2_cls_ssg--log_dirpointnet2_cls_ssgpythontest_classification.py--log_di......
  • Qt程序运行报错
    报错内容PC环境为Ubuntu20.04,Qt版本是Qt5.12.9,AsensingViewer是编译好的程序./AsensingViewer:errorwhileloadingsharedlibraries:libicudata.so.56:cannotopensharedobjectfile:Nosuchfileordirectory问题分析查看程序依赖lddAsensingViewer注意到有个......
  • Windows库链接报错
    问题回溯今天拿到别人已经编译好的库,发现在链接的时候出现了报错[9/912.7/sec]LinkingCXXsharedmodulebin\plugins\AsensingPlugin\AsensingPlugin.dllFAILED:bin/plugins/AsensingPlugin/AsensingPlugin.dllcmd.exe/C"cd.&&"C:\ProgramFiles\CMake\bin\cmake.e......
  • foxy rviz2 "rviz_common/Time"报错问题
    报错内容Theclassrequiredforthispanel,'rviz_common/Time',couldnotbeloaded.Error:Accordingtotheloadedplugindescriptionstheclassrviz_common/Timewithbaseclasstyperviz_common::Paneldoesnotexist.DeclaredtypesareTeleopPanel......
  • CentOS加载yum源时报错 [Errno 14] HTTP Error 404 - Not Found Trying other mirror.
    报错内容:[[email protected]]#yumrepolistLoadedplugins:fastestmirror,product-id,search-disabled-repos,subscription-managerThissystemisnotregisteredtoRedHatSubscriptionManagement.Youcanusesubscription-managertoregister.Determiningf......
  • P3592 [POI2015] MYJ
    P3592[POI2015]MYJ要求总和最大,有两张思路:贪心和dp。稍微想一下,发现贪心思考量太大,考虑dp观察n的数据范围,以及转移方式,可以想到区间dp发现转移跟区间最小值有关,设\(f_{l,r,k}\)为区间\([l,r]\)中最小值不小于\(x\)的答案。转移枚举最小值的位置\(p\),\(f_{l,r,k}......
  • 洛谷P3498 [POI2010] KOR-Beads 题解
    P3498[POI2010]KOR-Beads对于数列${A_i}$,求$k$使数列被分为$\lfloor\frac{n}{k}\rfloor$个部分后不同子数列种类最多(子串翻转前后为一类子串)很容易想到:枚举$k\\in\[1,n]$,记录每个$k$下不同种类数,然后取最优即可,那么问题来了:如何计算种类数?暴戾算法:一种纯......
  • 【踩坑随笔】Kaggle安装langchain相关依赖报错
    kaggle执行语句%pipinstalldatasetslangchainsentence_transformerstqdmchromadblangchain_wenxin安装langchain相关依赖报错的时候出现了以下报错主要是版本不匹配,报错什么就再加载什么就可以了,执行下面的语句%pipinstallkeras-core执行结果%pipinstallw......
  • 前端报错 request to https://registry.npm.taobao.org/yorkie/download/yorkie-2.0.0
    前端npminstall报错:npmERR!requesttohttps://registry.npm.taobao.org/yorkie/download/yorkie-2.0.0.tgzfailed,reason:certificatehasexpired解决方式://1.清空缓存npmcacheclean--force//2.切换新源:npmconfigsetregistry镜像源npmconfig......