简体   繁体   English

编译在Eclipse中有效,但在maven中无效

[英]Compilation works in Eclipse but not in maven

The following piece of code using apache poi library results in compilation error when using maven with jdk 7. It works when using jdk 8. 以下代码使用apache poi库,将maven与jdk 7一起使用时会导致编译错误。在使用jdk 8时可以使用。

    cell.getCellTypeEnum()

    [ERROR]   symbol:   method getCellTypeEnum()
    [ERROR]   location: variable cell of type org.apache.poi.ss.usermodel.Cell

The poi library used is 3.17 for both scenarios 两种情况下使用的poi库均为3.17

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

The maven dependency tree is as follows. Maven依赖树如下。

[INFO] com.iris.gst:txform:jar:1.0-SNAPSHOT
[INFO] +- org.apache.poi:poi-ooxml:jar:3.17:compile
[INFO] |  +- org.apache.poi:poi:jar:3.17:compile
[INFO] |  |  +- commons-codec:commons-codec:jar:1.10:compile
[INFO] |  |  \- org.apache.commons:commons-collections4:jar:4.1:compile
[INFO] |  +- org.apache.poi:poi-ooxml-schemas:jar:3.17:compile
[INFO] |  |  \- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
[INFO] |  |     \- stax:stax-api:jar:1.0.1:compile
[INFO] |  \- com.github.virtuald:curvesapi:jar:1.04:compile
[INFO] \- junit:junit:jar:3.8.1:test

It also works perfectly in Eclipse. 它也可以在Eclipse中完美运行。 The eclipse project has been created using mvn eclipse:eclipse. 使用mvn eclipse:eclipse创建了eclipse项目。 Why does it not work with jdk 7 ? 为什么它不适用于jdk 7?

The problem has been solved. 问题已经解决。 In JDK 7 jre/lib/ext there is a poi-3.6.jar present. 在JDK 7 jre / lib / ext中,存在poi-3.6.jar。 That was causing the problem. 那就是问题所在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM