[英]Getting :: java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.put(Ljava/lang/Object;)V
I am using the Poi(poi, poi-ooxml-schemas,poi-ooxml-4.4.1 ) api for export-import operation, and now upgraded xmlbeans from 3.0.2 to 5.0.1 version, after upgrading the xmlbeans-5.0.1 getting error while creating new SXSSFWorkbook(100);我正在使用 Poi(poi, poi-ooxml-schemas,poi-ooxml-4.4.1 ) api 进行导出-导入操作,现在在升级 xmlbeans-5.0 后将 xmlbeans 从 3.0.2 升级到 5.0.1 版本。 1 创建新的 SXSSFWorkbook(100) 时出错;
.... java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.put(Ljava/lang/Object;)V java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.xssf.model.SharedStringsTable .... java.lang.NoSuchMethodError: org.apache.xmlbeans.XmlOptions.put(Ljava/lang/Object;)V java.lang.NoClassDefFoundError: Could not initialize class org.apache.poi.xssf.model.SharedStringsTable
and using jaxb-api-2.4.0-b180830.0359 version.并使用 jaxb-api-2.4.0-b180830.0359 版本。
I found the following dependency in my pom.xml code and once i removed it.It worked fine for me.我在我的 pom.xml 代码中发现了以下依赖项,一旦我删除它。它对我来说很好。
<dependency>
<groupId>org.apache.servicemix.bundles</groupId>
<artifactId>org.apache.servicemix.bundles.poi</artifactId>
<version>4.1.2_1</version>
</dependency>
So remove it and it will work.所以删除它,它会工作。
I had updated to XMLBeans 5.0.3 earlier.我之前已经更新到 XMLBeans 5.0.3。 So to fix this I had to update to latest POI (I had the 4.xx series of POI earlier):所以要解决这个问题,我必须更新到最新的 POI(我之前有 4.xx 系列的 POI):
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.2</version>
</dependency>
I solved this problem by simply removing all packages of xmlbeans in my repository and reloading maven projects.我通过简单地删除我的存储库中的所有 xmlbeans 包并重新加载 maven 项目来解决了这个问题。
In most cases, if a java.lang.NoSuchMethodError
error occurs, the cause could be a dependency package conflict.在大多数情况下,如果出现java.lang.NoSuchMethodError
错误,原因可能是依赖 package 冲突。
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
You can try this also or can move to higher/lower dependency
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.