我已将Neo4j 3.0.1嵌入到Java 8应用程序中,但我一直遇到SPI问题。
从IntelliJ内部运行会产生预期的正确结果,但是一旦我将工件构建到JAR,运行它并尝试写入Neo4j,我得到以下异常:
Caused by: org.neo4j.kernel.impl.store.UnderlyingStorageException: java.lang.IllegalArgumentException: An SPI class of type org.apache.lucene.codecs.PostingsFormat with name 'BlockTreeOrds' does not exist. You need to add the corresponding JAR file supporting this SPI to your classpath. The current classpath supports the following names: [Lucene50]
at org.neo4j.kernel.impl.transaction.command.LabelUpdateWork.apply(LabelUpdateWork.java:62)
at org.neo4j.kernel.impl.transaction.command.LabelUpdateWork.apply(LabelUpdateWork.java:33)
at org.neo4j.concurrent.WorkSync.doSynchronizedWork(WorkSync.java:121)
at org.neo4j.concurrent.WorkSync.apply(WorkSync.java:90)
at org.neo4j.kernel.impl.transaction.command.IndexBatchTransactionApplier.close(IndexBatchTransactionApplier.java:105)
at org.neo4j.kernel.impl.api.BatchTransactionApplierFacade.close(BatchTransactionApplierFacade.java:70)
at org.neo4j.kernel.impl.storageengine.impl.recordstorage.RecordStorageEngine.apply(RecordStorageEngine.java:336)
at org.neo4j.kernel.impl.api.TransactionRepresentationCommitProcess.applyToStore(TransactionRepresentationCommitProcess.java:78)
... 25 more
似乎没有异常启动Neo4j所以我假设某些依赖关系没有通过Maven构建解决。
我的pom.xml
文件中有以下内容:
<dependency>
<groupId>com.sparkjava</groupId>
<artifactId>spark-core</artifactId>
<version>2.5</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j</artifactId>
<version>3.0.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.21</version>
</dependency>
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-codecs</artifactId>
<version>5.5.0</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-slf4j</artifactId>
<version>3.0.0-M02</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.6.2</version>
</dependency>
<dependency>
<groupId>com.github.jknack</groupId>
<artifactId>handlebars</artifactId>
<version>4.0.5</version>
</dependency>
<dependency>
<groupId>com.opencsv</groupId>
<artifactId>opencsv</artifactId>
<version>3.7</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
</dependency>
如何解决此问题?
更新:
我用一个非常简单的空白项目重新创建了这个问题,如果你想在你的最后运行它,可以在这里找到来源:https://github.com/SeanNieuwoudt/neo4j-spi
答案 0 :(得分:1)
我接受了你的项目,并在我的日食中执行。我没有问题。以下是启动后的控制台日志:
[Thread-0] INFO org.eclipse.jetty.util.log - 记录已初始化@ 473ms [Thread-0] INFO spark.embeddedserver.jetty.EmbeddedJettyServer - == Spark点燃了...... [Thread-0] INFO spark.embeddedserver.jetty.EmbeddedJettyServer - &gt;&gt;听取0.0.0.0:8080 [Thread-0] INFO org.eclipse.jetty.server.Server - jetty-9.3.6.v20151106 [Thread-0] INFO org.eclipse.jetty.server.ServerConnector - 已启动ServerConnector @ 5aa07ed2 {HTTP / 1.1,[http / 1.1]} {0.0.0.0:8080} [Thread-0] INFO org.eclipse.jetty.server.Server - 已启动@ 772ms
时我的输出打印为&#39; Hello World&#34;
我遵循的步骤:
1)从您的github网址下载您的项目 2)导入为指向java 8的maven项目 3)Maven安装成功 3)跑主班 4)在浏览器中看到输出。
我是否缺少复制实际问题的步骤?
或者与你的maven有关。可以在运行maven install之后检查你的maven依赖项,看看是否下载了预期的jar。
祝你好运。答案 1 :(得分:0)
尝试添加以下依赖项:
<dependency>
<groupId>org.apache.lucene</groupId>
<artifactId>lucene-backward-codecs</artifactId>
<version>5.5.0</version>
</dependency>
答案 2 :(得分:0)