背景:要实现一个需求,按照word模板合成一定的内容,给到前端,但是却跌到在了第一步,就是这个依赖的问题上
这个问题归根到底就是这个依赖冲突问题,
可是让我奇怪的是我用那个依赖分析器解决了poi-tl文件的冲突,因为我之前还使用了ali的easyexcel好多使用这个poi-相关的东西
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>easyexcel</artifactId>
<version>3.1.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.xmlbeans</groupId>
<artifactId>xmlbeans</artifactId>
</exclusion>
</exclusions>
</dependency>
从这个easyexcel中先把依赖排除掉,然后一直报这个错误,无奈之下就开始看这个依赖树
poi-ooxml-lite:52.2 (compile)
poi-ooxml-schemas:4.1.2 (compile)
poi-ooxml:5.2.2 (compile)
poi-tl:1.12.0 (compile)
poi:52.2 (compile)
最重要的是并没有冲突的标识,但是我却发现了这个poi-ooxml-schemas:4.1.2 (compile)的版本和别的不一样,于是想是不是这个有问题呢?于是我赶紧把这个排除了
<exclusion>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
</exclusion>
接着重新导入一下这些依赖,,文章来源:https://www.toymoban.com/news/detail-722909.html
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>5.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.2.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
</dependency>
运行之后成功生成了对应的代码,这个问题也启示我,以后分析这个依赖的时候不能光依靠idea的依赖分析,也要多关注这个版本问题。。文章来源地址https://www.toymoban.com/news/detail-722909.html
到了这里,关于poi报错 Exception in thread “main“ java.lang.NoSuchFieldError: Factory的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!