使用batchInserter批量导入neo4j数据时报错

weixin_37736728 2018-04-03 10:46:52
我使用官网文档的示例代码运行出现IllegalArgumentException错误。
neo4j数据库版本2.3.1,neo4j-kernel包的版本2.3.1



import org.neo4j.unsafe.batchinsert.BatchInserters;
import org.neo4j.unsafe.batchinsert.BatchInserter;
import org.neo4j.graphdb.Label;
import org.neo4j.graphdb.DynamicLabel;
import java.io.File;
import java.util.Map;
import java.util.HashMap;
import org.neo4j.graphdb.RelationshipType;
import org.neo4j.graphdb.DynamicRelationshipType;


public class RunNeo4jBatch {
public static void main(String[] args) {
BatchInserter inserter = null;
try
{
inserter = BatchInserters.inserter(
new File( "target/batchinserter-example1" ).getAbsolutePath() );

Label personLabel = DynamicLabel.label( "Person" );
inserter.createDeferredSchemaIndex( personLabel ).on( "name" ).create();

Map<String, Object> properties = new HashMap<String, Object>();

properties.put( "name", "Mattias" );
long mattiasNode = inserter.createNode( properties, personLabel );

properties.put( "name", "Chris" );
long chrisNode = inserter.createNode( properties, personLabel );

RelationshipType knows = DynamicRelationshipType.withName( "KNOWS" );
inserter.createRelationship( mattiasNode, chrisNode, knows, null );
}
catch (Exception e) {
e.printStackTrace();
}
finally
{
if ( inserter != null )
{
inserter.shutdown();
}
}
}
}

...全文
904 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
weixin_37736728 2018-04-03
  • 打赏
  • 举报
回复
原来还需要一个包neo4j-lucene-index
weixin_37736728 2018-04-03
  • 打赏
  • 举报
回复
报错信息如下

java.lang.IllegalArgumentException: No schema index provider org.neo4j.kernel.api.index.SchemaIndexProvider found. Kernel extensions available on classpath: 

Class path entries:
  E:\jdk1.8.0_20_64\jre\lib\charsets.jar
  E:\jdk1.8.0_20_64\jre\lib\deploy.jar
  E:\jdk1.8.0_20_64\jre\lib\ext\access-bridge-64.jar
  E:\jdk1.8.0_20_64\jre\lib\ext\cldrdata.jar
  E:\jdk1.8.0_20_64\jre\lib\ext\dnsns.jar
  E:\jdk1.8.0_20_64\jre\lib\ext\jaccess.jar
  E:\jdk1.8.0_20_64\jre\lib\ext\jfxrt.jar
  E:\jdk1.8.0_20_64\jre\lib\ext\localedata.jar
  E:\jdk1.8.0_20_64\jre\lib\ext\nashorn.jar
  E:\jdk1.8.0_20_64\jre\lib\ext\sunec.jar
  E:\jdk1.8.0_20_64\jre\lib\ext\sunjce_provider.jar
  E:\jdk1.8.0_20_64\jre\lib\ext\sunmscapi.jar
  E:\jdk1.8.0_20_64\jre\lib\ext\sunpkcs11.jar
  E:\jdk1.8.0_20_64\jre\lib\ext\zipfs.jar
  E:\jdk1.8.0_20_64\jre\lib\javaws.jar
  E:\jdk1.8.0_20_64\jre\lib\jce.jar
  E:\jdk1.8.0_20_64\jre\lib\jfr.jar
  E:\jdk1.8.0_20_64\jre\lib\jfxswt.jar
  E:\jdk1.8.0_20_64\jre\lib\jsse.jar
  E:\jdk1.8.0_20_64\jre\lib\management-agent.jar
  E:\jdk1.8.0_20_64\jre\lib\plugin.jar
  E:\jdk1.8.0_20_64\jre\lib\resources.jar
  E:\jdk1.8.0_20_64\jre\lib\rt.jar
  E:\workspace\myWorkspace\batchTest\target\classes
  E:\workspace\myWorkspace\batchTest\lib\spring-aspects-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-context-support-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-aop-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-expression-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-instrument-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-instrument-tomcat-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-beans-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-jdbc-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-context-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-core-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-jms-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-oxm-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-messaging-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-tx-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\aopalliance-1.0.jar
  E:\workspace\myWorkspace\batchTest\lib\commons-logging-1.2.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-orm-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-test-4.3.14.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-batch-infrastructure-2.2.6.RELEASE.jar
  E:\workspace\myWorkspace\batchTest\lib\spring-batch-core-2.2.6.RELEASE.jar
  D:\mvn_repository\org\neo4j\neo4j-kernel\2.3.1\neo4j-kernel-2.3.1.jar
  D:\mvn_repository\org\neo4j\neo4j-primitive-collections\2.3.1\neo4j-primitive-collections-2.3.1.jar
  D:\mvn_repository\org\neo4j\neo4j-unsafe\2.3.1\neo4j-unsafe-2.3.1.jar
  D:\mvn_repository\org\neo4j\neo4j-function\2.3.1\neo4j-function-2.3.1.jar
  D:\mvn_repository\org\neo4j\neo4j-io\2.3.1\neo4j-io-2.3.1.jar
  D:\mvn_repository\org\apache\commons\commons-lang3\3.3.2\commons-lang3-3.3.2.jar
  D:\mvn_repository\org\neo4j\neo4j-csv\2.3.1\neo4j-csv-2.3.1.jar
  D:\mvn_repository\org\neo4j\neo4j-logging\2.3.1\neo4j-logging-2.3.1.jar
  E:\IDEA\lib\idea_rt.jar
	at org.neo4j.kernel.api.index.SchemaIndexProvider$2.select(SchemaIndexProvider.java:150)
	at org.neo4j.kernel.extension.KernelExtensions.resolveDependency(KernelExtensions.java:118)
	at org.neo4j.unsafe.batchinsert.BatchInserterImpl.<init>(BatchInserterImpl.java:327)
	at org.neo4j.unsafe.batchinsert.BatchInserters.inserter(BatchInserters.java:187)
	at org.neo4j.unsafe.batchinsert.BatchInserters.inserter(BatchInserters.java:153)
	at org.neo4j.unsafe.batchinsert.BatchInserters.inserter(BatchInserters.java:130)
	at org.neo4j.unsafe.batchinsert.BatchInserters.inserter(BatchInserters.java:74)
	at org.neo4j.unsafe.batchinsert.BatchInserters.inserter(BatchInserters.java:48)
	at org.suanhua.frdnet.tool.RunNeo4jBatch.main(RunNeo4jBatch.java:19)
weixin_37736728 2018-04-03
  • 打赏
  • 举报
回复
希望大神指教

2,208

社区成员

发帖
与我相关
我的任务
社区描述
其他数据库开发 其他数据库
社区管理员
  • 其他数据库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧