gpt4 book ai didi

java - Maven 构建在运行时抛出 JodaTime 异常

转载 作者:太空宇宙 更新时间:2023-11-04 07:05:22 24 4
gpt4 key购买 nike

我正在使用 corenlp 3.3.1 构建一个基于 Maven 的 Java 应用程序。

显着的 pom.xml 依赖项是

        <dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.3.1</version>
</dependency>

<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.3.1</version>
<classifier>models</classifier>
</dependency>

正在运行

 mvn dependency:tree

给出:

[INFO] +- log4j:log4j:jar:1.2.17:compile
[INFO] +- commons-logging:commons-logging:jar:1.1.1:compile
[INFO] +- edu.stanford.nlp:stanford-corenlp:jar:3.3.1:compile
[INFO] | +- com.io7m.xom:xom:jar:1.2.10:compile
[INFO] | | +- xml-apis:xml-apis:jar:1.3.03:compile
[INFO] | | +- xerces:xercesImpl:jar:2.8.0:compile
[INFO] | | \- xalan:xalan:jar:2.7.0:compile
[INFO] | +- joda-time:joda-time:jar:2.1:compile
[INFO] | +- de.jollyday:jollyday:jar:0.4.7:compile
[INFO] | | \- javax.xml.bind:jaxb-api:jar:2.2.7:compile
[INFO] | \- com.googlecode.efficient-java-matrix-library:ejml:jar:0.23:compile
[INFO] \- edu.stanford.nlp:stanford-corenlp:jar:models:3.3.1:compile

我的代码包括:

Properties props = new Properties();
props.put("annotators",
"tokenize, ssplit, pos, lemma, ner, parse, dcoref");
this.pipeline = new StanfordCoreNLP(props);

到达这里后会抛出异常:

Adding annotator tokenize
Adding annotator ssplit
Adding annotator pos
Reading POS tagger model from edu/stanford/nlp/models/pos-tagger/english-left3words/english-left3words-distsim.tagger ... done [1.2 sec].
Adding annotator lemma
Adding annotator ner
Loading classifier from edu/stanford/nlp/models/ner/english.all.3class.distsim.crf.ser.gz ... done [4.8 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.muc.7class.distsim.crf.ser.gz ... done [2.3 sec].
Loading classifier from edu/stanford/nlp/models/ner/english.conll.4class.distsim.crf.ser.gz ... done [3.8 sec].

异常(exception)是

java.lang.NoSuchMethodError: org.joda.time.Duration.compareTo(Lorg/joda/time/ReadableDuration;)I
at edu.stanford.nlp.time.SUTime$Duration.compareTo(SUTime.java:3671)
at edu.stanford.nlp.time.SUTime$Duration.max(SUTime.java:3753)
at edu.stanford.nlp.time.SUTime$Time.difference(SUTime.java:1434)
at edu.stanford.nlp.time.SUTime$Range.<init>(SUTime.java:4072)
at edu.stanford.nlp.time.SUTime.<clinit>(SUTime.java:655)
at edu.stanford.nlp.time.EnglishTimeExpressionPatterns.initTimeUnitsMap(EnglishTimeExpressionPatterns.java:1542)
at edu.stanford.nlp.time.EnglishTimeExpressionPatterns.<init>(EnglishTimeExpressionPatterns.java:47)
at edu.stanford.nlp.time.TimeExpressionExtractorImpl.init(TimeExpressionExtractorImpl.java:65)
at edu.stanford.nlp.time.TimeExpressionExtractorImpl.<init>(TimeExpressionExtractorImpl.java:37)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:526)
at java.lang.Class.newInstance(Class.java:374)
at edu.stanford.nlp.time.TimeExpressionExtractorFactory.create(TimeExpressionExtractorFactory.java:45)
at edu.stanford.nlp.time.TimeExpressionExtractorFactory.createExtractor(TimeExpressionExtractorFactory.java:28)
at edu.stanford.nlp.ie.regexp.NumberSequenceClassifier.<init>(NumberSequenceClassifier.java:79)
at edu.stanford.nlp.ie.NERClassifierCombiner.<init>(NERClassifierCombiner.java:67)
at edu.stanford.nlp.pipeline.StanfordCoreNLP$6.create(StanfordCoreNLP.java:619)
at edu.stanford.nlp.pipeline.AnnotatorPool.get(AnnotatorPool.java:81)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.construct(StanfordCoreNLP.java:260)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:127)
at edu.stanford.nlp.pipeline.StanfordCoreNLP.<init>(StanfordCoreNLP.java:123)
at com.othermaps.analysis.madhatter.service.ServiceImpl.initTAEngines(ServiceImpl.java:49)
... 34 more

我假设这是“JodaTime 版本错误”问题 - 但是,如果我从 corenlp 的依赖项中明确排除 JodaTime Artifact ,我找不到不会生成此异常的版本:

<dependency>
<groupId>edu.stanford.nlp</groupId>
<artifactId>stanford-corenlp</artifactId>
<version>3.3.1</version>
<exclusions>
<exclusion>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
</exclusion>
</exclusions>
</dependency>

并手动添加显式定义的版本

例如

<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.1</version>
</dependency>

(是的,我知道这与自动添加的依赖项版本相同:这只是我尝试过的过程的一个示例;-)

感谢所有帮助。

D

最佳答案

我的最后一条评论包含了答案——它与 CXF 包中包含的 Joda jar 发生冲突。

关于java - Maven 构建在运行时抛出 JodaTime 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21487476/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com