[英]org.apache.lucene.analysis.StandardAnalyzer cannot be resolved
When implementing tokenization by using Lucene a problem related to org.apache.lucene.analysis.StandardAnalyzer
occurred as the following exception was thrown: 使用Lucene实施标记化时 ,发生与org.apache.lucene.analysis.StandardAnalyzer
相关的问题,因为引发了以下异常:
The import org.apache.lucene.analysis.StandardAnalyzer cannot be resolved 导入org.apache.lucene.analysis.StandardAnalyzer无法解析
I added dependencies to Maven pom.xml (see below) but the same exception was thrown again. 我向Maven pom.xml中添加了依赖项(见下文),但是再次抛出了相同的异常。
I used those dependencies: 我使用了那些依赖项:
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-core</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers-common</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queryparser</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-queries</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-test-framework</artifactId>
<version>5.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-analyzers</artifactId>
<version>3.6.2</version>
</dependency>
Remove the lucene-analyzers
dependency. 删除lucene-analyzers
依赖项。
You can't mix-and-match package versions with lucene, and the lucene-analyzers
package is no longer used. 您不能将混合版本的软件包与Lucene混合使用,并且不再使用lucene-analyzers
软件包。 You already have the dependency to lucene-analyzers-common
, which is what you should be using. 您已经具有对lucene-analyzers-common
的依赖,这是您应该使用的。
Also, you need to import org.apache.lucene.analysis.standard.StandardAnalyzer
, instead of org.apache.lucene.analysis.StandardAnalyzer
. 另外,您需要导入org.apache.lucene.analysis.standard.StandardAnalyzer
,而不是org.apache.lucene.analysis.StandardAnalyzer
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.