2017-04-24 77 views
1

我需要幫助連接neo4j數據庫到彈簧引導。我整天都在搜索,但無法弄清楚。我可以創建一個Spring引導應用程序,創建一個REST控制器調用服務,然後創建SQl的Spring數據JPA存儲庫,但無法爲圖形數據庫執行此操作。任何人都可以幫助我配置Graph數據庫以進行引導。 我是Neo4j的新手,並已分配任務。連接Neo4J與SpringBoot

謝謝。 我說什麼任何教程告訴我:

<parent> 
    <groupId>org.springframework.boot</groupId> 
    <artifactId>spring-boot-starter-parent</artifactId> 
    <version>1.4.3.RELEASE</version> 
</parent> 
<dependencies> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-web</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-jpa</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.boot</groupId> 
     <artifactId>spring-boot-starter-data-rest</artifactId> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.data</groupId> 
     <artifactId>spring-data-neo4j</artifactId> 
     <version>4.2.3.RELEASE</version> 
    </dependency> 
    <!-- https://mvnrepository.com/artifact/org.springframework.data/spring-data-neo4j-rest --> 
    <dependency> 
     <groupId>org.springframework.data</groupId> 
     <artifactId>spring-data-neo4j-rest</artifactId> 
     <version>3.4.6.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.neo4j</groupId> 
     <artifactId>neo4j-configuration</artifactId> 
     <version>3.2.0-alpha08</version> 
    </dependency> 


</dependencies> 
<properties> 
    <start-class>com.sumit.demo.AppBootConfig</start-class> 
    <java.version>1.8</java.version> 
</properties> 
<build> 
    <finalName>people</finalName> 
</build> 

我主要是:

@SpringBootApplication(exclude = { Neo4jDataAutoConfiguration.class }) 
@EnableAutoConfiguration(exclude = { DataSourceAutoConfiguration.class }) 
public class AppBootConfig extends SpringBootServletInitializer { 
public static void main(String[] args) { 
    SpringApplication.run(AppBootConfig.class, args); 
    } 
} 

我試圖來配置,但得到這個:

017-04-25 01:10:03.316 WARN 5772 --- [   main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanDefinitionStoreException: Failed to process import candidates for configuration class [com.sumit.demo.AppBootConfig]; nested exception is java.io.FileNotFoundException: class path resource [org/springframework/data/neo4j/config/Neo4jConfiguration.class] cannot be opened because it does not exist 

2017-04- 25 01:10:03.323 ERROR 5772 --- [main] osbfsDefaultListableBeanFactory:破壞bean的機智方法^ h名「org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory」拋出一個異常

java.lang.IllegalStateException:ApplicationEventMulticaster未初始化 - 多播打電話通過上下文事件之前,「刷新」:org.springframework.boot.context.embedded .AnnotationConfigEmbeddedWebApplicationContext @ 2f9f7dcf:啓動日期[Tue Apr 25 01:10:02 IST 2017];在org.springframework.context.support.AbstractApplicationContext.getApplicationEventMulticaster(AbstractApplicationContext.java:404)上下文層次 的根[彈簧上下文4.3.5.RELEASE.jar:4.3.5.RELEASE] 在org.springframework.context .support.ApplicationListenerDetector.postProcessBeforeDestruction(ApplicationListenerDetector.java:97)〜[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.beans.factory.support.DisposableBeanAdapter.destroy(DisposableBeanAdapter .java:253)〜[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroyBean(DefaultSingletonBeanRegistry.java:578)[spring- beans-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingleton(DefaultSingletonBeanRegis try.java:554)[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingleton(DefaultListableBeanFactory.java:959)[spring- beans-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.destroySingletons(DefaultSingletonBeanRegistry.java:523)[spring-beans-4.3.5.RELEASE.jar :4.3.5.RELEASE] at org.springframework.beans.factory.support.DefaultListableBeanFactory.destroySingletons(DefaultListableBeanFactory.java:966)[spring-beans-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.destroyBeans(AbstractApplicationContext.java:1033)[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.refresh (AbstractA [spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:122)[spring- boot-1.4.3.RELEASE.jar:1.4.3.RELEASE] at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)[spring-boot-1.4.3.RELEASE.jar:1.4.3 .RELEASE] 在org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)[彈簧引導1.4.3.RELEASE.jar:1.4.3.RELEASE] 在org.springframework.boot.SpringApplication。運行(SpringApplication.java:315)[spring-boot-1.4.3.RELEASE.jar:1.4.3。發佈] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1186)[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE] at org.springframework.boot.SpringApplication.run (SpringApplication.java:1175)[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE] at com.sumit.demo.AppBootConfig.main(AppBootConfig.java:15)[classes /:na]

2017年4月25日01:10:03.334 ERROR 5772 --- [主] osboot.SpringApplication:應用程序啓動失敗

org.springframework.beans.factory.BeanDefinitionStoreException:無法處理進口候選人配置類[com.sumit.demo.AppBootConfig];嵌套異常是java.io.FileNotFoundException:無法打開類路徑資源[org/springframework/data/neo4j/config/Neo4jConfiguration.class]因爲它不存在 at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser .java:541)〜[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.processDeferredImportSelectors(ConfigurationClassParser.java:475)〜[spring-context -4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.parse(ConfigurationClassParser.java:184)〜[spring-context-4.3.5.RELEASE.jar:4.3 .5.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.processConfigBeanDefinitions(ConfigurationClassPostProcessor.java:308)〜[spring-context-4.3.5.RELEASE.jar:4 .3.5.RELEASE] at org.springframework.context.annotation.ConfigurationClassPostProcessor.postProcessBeanDefinitionRegistry(ConfigurationClassPostProcessor.java:228)〜[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework .context.support.PostProcessorRegistrationDelegate.invokeBeanDefinitionRegistryPostProcessors(PostProcessorRegistrationDelegate.java:270)〜[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.context.support.PostProcessorRegistrationDelegate.invokeBeanFactoryPostProcessors(PostProcessorRegistrationDelegate .java:93)〜[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.context.support.AbstractApplicationContext.invokeBeanFactoryPostProcessors(AbstractApplicationContext.java:686)〜[spring-context -4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.conte xt.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:524)〜[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh( EmbeddedWebApplicationContext.java:122)〜[彈簧引導1.4.3.RELEASE.jar:1.4.3.RELEASE] 在org.springframework.boot.SpringApplication.refresh(SpringApplication.java:761)[彈簧引導1.4 .3.RELEASE.jar:1.4.3.RELEASE] at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:371)[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.run .java:1186)[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE] at org.springframework.boot.SpringApplication.run(SpringApplication.java:1175)[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE] at com.sumit.demo.AppBootConfig.main(AppBootConfig .java:15)[classes /:na] 由於:java.io.FileNotFoundException:無法打開類路徑資源[org/springframework/data/neo4j/config/Neo4jConfiguration.class],因爲它不存在 at org .springframework.core.io.ClassPathResource.getInputStream(ClassPathResource.java:172)〜[彈簧芯4.3.5.RELEASE.jar:4.3.5.RELEASE] 在org.springframework.core.type.classreading.SimpleMetadataReader 。(SimpleMetadataReader.java:50)〜[spring-core-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java:98) 〜[彈簧芯4.3.5.RELEASE.jar:4.3.5.REL EASE] at org。springframework.boot.type.classreading.ConcurrentReferenceCachingMetadataReaderFactory.createMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:89)〜[spring-boot-1.4.3.RELEASE.jar:1.4.3.RELEASE] at org.springframework.boot.type.classreading。 ConcurrentReferenceCachingMetadataReaderFactory.getMetadataReader(ConcurrentReferenceCachingMetadataReaderFactory.java:76)〜[彈簧引導1.4.3.RELEASE.jar:1.4.3.RELEASE] 在org.springframework.core.type.classreading.SimpleMetadataReaderFactory.getMetadataReader(SimpleMetadataReaderFactory.java: 93)〜[彈簧芯4.3.5.RELEASE.jar:4.3.5.RELEASE] 在org.springframework.context.annotation.ConfigurationClassParser.asSourceClass(ConfigurationClassParser.java:633)〜[彈簧上下文4.3。 5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser $ SourceClass.getSuperClass(Confi gurationClassParser.java:797)〜[彈簧上下文4.3.5.RELEASE.jar:4.3.5.RELEASE] 在org.springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:308)〜[彈簧上下文4.3.5.RELEASE.jar:4.3.5.RELEASE] 在org.springframework.context.annotation.ConfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:230)〜[彈簧上下文4.3.5.RELEASE.jar: 4.3.5.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.processMemberClasses(ConfigurationClassParser.java:329)〜[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org。 springframework.context.annotation.ConfigurationClassParser.doProcessConfigurationClass(ConfigurationClassParser.java:247)〜[彈簧上下文4.3.5.RELEASE.jar:4.3.5.RELEASE] 在org.springframework.context.annotation.Co nfigurationClassParser.processConfigurationClass(ConfigurationClassParser.java:230)〜[spring-context-4.3.5.RELEASE.jar:4.3.5.RELEASE] at org.springframework.context.annotation.ConfigurationClassParser.processImports(ConfigurationClassParser.java:532) 〜[彈簧上下文4.3.5.RELEASE.jar:4.3.5.RELEASE] ... 15共同幀省略

回答

0

首先,你的聚甲醛是相當混亂。只添加所需的依賴關係。你只需要這個

<dependency> 
     <groupId>org.springframework.data</groupId> 
     <artifactId>spring-data-neo4j</artifactId> 
     <version>4.1.5.RELEASE</version> 
    </dependency> 
    <dependency> 
     <groupId>org.springframework.data</groupId> 
     <artifactId>spring-data-neo4j-rest</artifactId> 
     <version>3.4.6.RELEASE</version> 
</dependency> 

主類中應該有這樣的事情

@SpringBootApplication 
@EnableNeo4jRepositories("com.in.neo4j.repository.neo") 

我不知道你爲什麼不包括一些autoconfigurations

+0

我得到這個錯誤這就是爲什麼我不包括他們。 '產生的原因:java.io.FileNotFoundException:類路徑的資源[組織/ springframework的/數據/ Neo4j的/配置/ Neo4jConfiguration.class]不能打開,因爲它不存在於'我想這可能工作 –

+0

仍然得到'類路徑的資源[組織/ springframework的/數據/ Neo4j的/配置/ Neo4jConfiguration.class]不能打開,因爲它沒有exist'錯誤 –

+0

檢查springboot父母和彈簧數據Neo4j的版本,如果他們是兼容的。 – pvpkiran