如何使用带有 IO Platform 1.1.3 的 Spring Data Neo4J 4 制作嵌入式服务器?

How can make an embedded server with Spring Data Neo4J 4 with IO Platform 1.1.3?

我正在尝试在 Spring Data Neo4J 4 上启动一个新应用程序。不过我在使用基本配置时遇到了一些问题。

Exception in thread "main" org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'repositoryEntityController' defined in URL [jar:file:/home/xenoterracide/.m2/repository/org/springframework/data/spring-data-rest-webmvc/2.4.0.RELEASE/spring-data-rest-webmvc-2.4.0.RELEASE.jar!/org/springframework/data/rest/webmvc/RepositoryEntityController.class]: Unsatisfied dependency expressed through constructor argument with index 0 of type [org.springframework.data.repository.support.Repositories]: : Error creating bean with name 'repositories' defined in class path resource [org/springframework/boot/autoconfigure/data/rest/SpringBootRepositoryRestMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.repository.support.Repositories]: Factory method 'repositories' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'characterRepository': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.neo4j.ogm.session.Session org.springframework.data.neo4j.repository.support.GraphRepositoryFactoryBean.session; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.neo4j.ogm.session.Session] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositories' defined in class path resource [org/springframework/boot/autoconfigure/data/rest/SpringBootRepositoryRestMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.repository.support.Repositories]: Factory method 'repositories' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'characterRepository': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.neo4j.ogm.session.Session org.springframework.data.neo4j.repository.support.GraphRepositoryFactoryBean.session; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.neo4j.ogm.session.Session] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.autowireConstructor(ConstructorResolver.java:185)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.autowireConstructor(AbstractAutowireCapableBeanFactory.java:1139)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1042)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
at com.xenoterracide.rpf.Application.main(Application.java:13)
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'repositories' defined in class path resource [org/springframework/boot/autoconfigure/data/rest/SpringBootRepositoryRestMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.repository.support.Repositories]: Factory method 'repositories' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'characterRepository': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.neo4j.ogm.session.Session org.springframework.data.neo4j.repository.support.GraphRepositoryFactoryBean.session; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.neo4j.ogm.session.Session] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1120)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1044)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 18 more
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.repository.support.Repositories]: Factory method 'repositories' threw exception; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'characterRepository': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.neo4j.ogm.session.Session org.springframework.data.neo4j.repository.support.GraphRepositoryFactoryBean.session; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.neo4j.ogm.session.Session] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 31 more
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'characterRepository': Injection of autowired dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.neo4j.ogm.session.Session org.springframework.data.neo4j.repository.support.GraphRepositoryFactoryBean.session; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.neo4j.ogm.session.Session] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:334)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.populateBean(AbstractAutowireCapableBeanFactory.java:1210)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:537)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:199)
at org.springframework.context.support.AbstractApplicationContext.getBean(AbstractApplicationContext.java:962)
at org.springframework.data.repository.support.Repositories.cacheRepositoryFactory(Repositories.java:95)
at org.springframework.data.repository.support.Repositories.populateRepositoryFactoryInformation(Repositories.java:88)
at org.springframework.data.repository.support.Repositories.<init>(Repositories.java:81)
at org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.repositories(RepositoryRestMvcConfiguration.java:182)
at org.springframework.boot.autoconfigure.data.rest.SpringBootRepositoryRestMvcConfiguration$$EnhancerBySpringCGLIB$cb88b30.CGLIB$repositories(<generated>)
at org.springframework.boot.autoconfigure.data.rest.SpringBootRepositoryRestMvcConfiguration$$EnhancerBySpringCGLIB$cb88b30$$FastClassBySpringCGLIB$e74ae25.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
at org.springframework.boot.autoconfigure.data.rest.SpringBootRepositoryRestMvcConfiguration$$EnhancerBySpringCGLIB$cb88b30.repositories(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 32 more
Caused by: org.springframework.beans.factory.BeanCreationException: Could not autowire field: private org.neo4j.ogm.session.Session org.springframework.data.neo4j.repository.support.GraphRepositoryFactoryBean.session; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.neo4j.ogm.session.Session] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:561)
at org.springframework.beans.factory.annotation.InjectionMetadata.inject(InjectionMetadata.java:88)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:331)
... 54 more
 Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.neo4j.ogm.session.Session] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1301)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1047)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:942)
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:533)
... 56 more

我目前没有 Neo4j 的配置,所以这可能是问题的一部分,尽管我在数据共享版本和其他方面遇到过问题。

我没有配置,因为文档说

InProcessServer is useful for test and development environments,

InProcessServer 在 4.0 中不作为 class 存在,我还没有设置远程服务器。

这是我目前对 pom.xml 的尝试,但我不认为它是完整的。

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xmlns="http://maven.apache.org/POM/4.0.0"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>

  <artifactId>rpf</artifactId>
  <version>0.1.0-SNAPSHOT</version>

  <properties>
    <spring-data-releasetrain.version>Gosling-RELEASE</spring-data-releasetrain.version>
    <spring-hateoas.version>0.19.0.RELEASE</spring-hateoas.version>
    <jackson.version>2.6.1</jackson.version>
  </properties>

    <dependency>
      <groupId>org.springframework.data</groupId>
      <artifactId>spring-data-neo4j</artifactId>
      <version>4.0.0.RELEASE</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-web</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
    <dependency>
      <groupId>org.springframework.boot</groupId>
      <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
      <groupId>org.hibernate</groupId>
      <artifactId>hibernate-validator</artifactId>
    </dependency>
  </dependencies>

  <parent>
    <groupId>io.spring.platform</groupId>
    <artifactId>platform-bom</artifactId>
    <version>1.1.3.RELEASE</version>
  </parent>

</project>

如何让嵌入式服务器在 IO Platform 1.1.3 上使用 Spring Data Neo4j 4?

更新

我已经稍微更新了我的依赖项。

 <properties>
    <spring-data-releasetrain.version>Gosling-RELEASE</spring-data-releasetrain.version>
    <spring-hateoas.version>0.19.0.RELEASE</spring-hateoas.version>
    <jackson.version>2.6.1</jackson.version>
    <spring-data-neo4j.version>4.0.0.RELEASE</spring-data-neo4j.version>
    <neo4j.version>2.2.5</neo4j.version>
    <neo4j-ogm.version>1.1.2</neo4j-ogm.version>
  </properties>

  <dependencies>
    <dependency>
      <groupId>com.xenoterracide</groupId>
      <artifactId>entity-api</artifactId>
    </dependency>
    <dependency>
      <groupId>com.xenoterracide</groupId>
      <artifactId>security-rbac-api</artifactId>
      <version>0.1.0-SNAPSHOT</version>
    </dependency>
    <dependency>
      <groupId>org.springframework.data</groupId>
      <artifactId>spring-data-neo4j</artifactId>
      <version>${spring-data-neo4j.version}</version>
    </dependency>

    <dependency>
      <groupId>org.springframework.data</groupId>
      <artifactId>spring-data-neo4j</artifactId>
      <version>${spring-data-neo4j.version}</version>
      <type>test-jar</type>
    </dependency>

    <dependency>
      <groupId>org.neo4j</groupId>
      <artifactId>neo4j-kernel</artifactId>
      <version>${neo4j.version}</version>
      <type>test-jar</type>
    </dependency>

    <dependency>
      <groupId>org.neo4j.app</groupId>
      <artifactId>neo4j-server</artifactId>
      <version>${neo4j.version}</version>
      <type>test-jar</type>
    </dependency>

    <dependency>
      <groupId>org.neo4j</groupId>
      <artifactId>neo4j-ogm</artifactId>
      <version>${neo4j-ogm.version}</version>
      <type>test-jar</type>
    </dependency>

    <dependency>
      <groupId>org.neo4j.test</groupId>
      <artifactId>neo4j-harness</artifactId>
      <version>${neo4j.version}</version>
    </dependency>

我确实复制了配置

package com.xenoterracide.rpf.config;

import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Scope;
import org.springframework.context.annotation.ScopedProxyMode;
import org.springframework.data.neo4j.config.Neo4jConfiguration;
import org.springframework.data.neo4j.server.InProcessServer;
import org.springframework.data.neo4j.server.Neo4jServer;

@Configuration
public class Neo4JDevelopmentConfig extends Neo4jConfiguration {

    @Bean
    @Override
    @Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
    public Session getSession() throws Exception {
        return super.getSession();
    }

    @Bean
    @Override
    public Neo4jServer neo4jServer() {
        return new InProcessServer();
    }

    @Bean
    @Override
    public SessionFactory getSessionFactory() {
        return new SessionFactory("com.xenoterracide.rpf");
    }
}

但这只会导致一组不同的例外情况

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'neo4jServer' defined in class path resource [com/xenoterracide/rpf/config/Neo4JDevelopmentConfig.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.neo4j.server.Neo4jServer]: Factory method 'neo4jServer' threw exception; nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/server/ConnectionFactory
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:599)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1119)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1014)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:504)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:476)
at org.springframework.beans.factory.support.AbstractBeanFactory.getObject(AbstractBeanFactory.java:303)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:299)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:194)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:755)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:757)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:480)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:686)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:320)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:957)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:946)
at com.xenoterracide.rpf.Application.main(Application.java:13)
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.neo4j.server.Neo4jServer]: Factory method 'neo4jServer' threw exception; nested exception is java.lang.NoClassDefFoundError: org/eclipse/jetty/server/ConnectionFactory
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:189)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:588)
... 17 more
Caused by: java.lang.NoClassDefFoundError: org/eclipse/jetty/server/ConnectionFactory
at org.neo4j.server.web.Jetty9WebServer.<init>(Jetty9WebServer.java:129)
at org.neo4j.server.CommunityNeoServer.createWebServer(CommunityNeoServer.java:122)
at org.neo4j.server.AbstractNeoServer.<init>(AbstractNeoServer.java:173)
at org.neo4j.server.CommunityNeoServer.<init>(CommunityNeoServer.java:87)
at org.neo4j.server.CommunityNeoServer.<init>(CommunityNeoServer.java:82)
at org.neo4j.harness.internal.InProcessServerBuilder.newServer(InProcessServerBuilder.java:70)
at org.neo4j.ogm.testutil.TestServer.<init>(TestServer.java:39)
at org.springframework.data.neo4j.server.InProcessServer.<init>(InProcessServer.java:26)
at com.xenoterracide.rpf.config.Neo4JDevelopmentConfig.neo4jServer(Neo4JDevelopmentConfig.java:26)
at com.xenoterracide.rpf.config.Neo4JDevelopmentConfig$$EnhancerBySpringCGLIB$f057415.CGLIB$neo4jServer(<generated>)
at com.xenoterracide.rpf.config.Neo4JDevelopmentConfig$$EnhancerBySpringCGLIB$f057415$$FastClassBySpringCGLIB$e02e6b.invoke(<generated>)
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228)
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:309)
at com.xenoterracide.rpf.config.Neo4JDevelopmentConfig$$EnhancerBySpringCGLIB$f057415.neo4jServer(<generated>)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:162)
... 18 more
 Caused by: java.lang.ClassNotFoundException: org.eclipse.jetty.server.ConnectionFactory
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 37 more

在 search.maven.org 上快速搜索完全限定的 class 名称表明您很可能遗漏了测试 JAR:

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-neo4j</artifactId>
  <version>4.0.0.RELEASE</version>
  <type>test-jar</type>
  <scope>test</scope>
</dependency>

这些版本似乎有效,

<properties>
  <spring-data-releasetrain.version>Gosling-RELEASE</spring-data-releasetrain.version>
  <spring-hateoas.version>0.19.0.RELEASE</spring-hateoas.version>
  <jackson.version>2.6.1</jackson.version>
  <spring-data-neo4j.version>4.0.0.RELEASE</spring-data-neo4j.version>
  <neo4j.version>2.2.5</neo4j.version>
  <neo4j-ogm.version>1.1.2</neo4j-ogm.version>
  <jetty.version>9.3.3.v20150827</jetty.version>
  <servlet-api.version>3.1.0</servlet-api.version>
</properties>

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-neo4j</artifactId>
  <version>${spring-data-neo4j.version}</version>
</dependency>

<dependency>
  <groupId>org.springframework.data</groupId>
  <artifactId>spring-data-neo4j</artifactId>
  <version>${spring-data-neo4j.version}</version>
  <type>test-jar</type>
</dependency>

<dependency>
  <groupId>org.neo4j</groupId>
  <artifactId>neo4j-kernel</artifactId>
  <version>${neo4j.version}</version>
  <type>test-jar</type>
</dependency>

<dependency>
  <groupId>org.neo4j.app</groupId>
  <artifactId>neo4j-server</artifactId>
  <version>${neo4j.version}</version>
  <type>test-jar</type>
</dependency>

<dependency>
  <groupId>org.neo4j</groupId>
  <artifactId>neo4j-ogm</artifactId>
  <version>${neo4j-ogm.version}</version>
  <type>test-jar</type>
</dependency>

<dependency>
  <groupId>org.neo4j.test</groupId>
  <artifactId>neo4j-harness</artifactId>
  <version>${neo4j.version}</version>
</dependency>

随着这个配置

@Configuration
public class Neo4JDevelopmentConfig extends Neo4jConfiguration {

@Bean
@Override
@Scope(value = "session", proxyMode = ScopedProxyMode.TARGET_CLASS)
public Session getSession() throws Exception {
    return super.getSession();
}

@Bean
@Override
public Neo4jServer neo4jServer() {
    return new InProcessServer();
}

@Bean
@Override
public SessionFactory getSessionFactory() {
    return new SessionFactory("com.xenoterracide.rpf");
}
}

Spring 引导的日志记录似乎关闭,例如默认情况下未设置颜色,并且未记录自动配置。我也收到了这些警告,但它们似乎没有任何影响。

2015-10-10 20:44:50,661  WARN 4j.ogm.authentication.CredentialsService: 55 - No credentials supplied
2015-10-10 20:44:50,671  WARN 4j.ogm.authentication.CredentialsService: 55 - No credentials supplied