Я пытаюсь подключить локально запущенный экземпляр neo4j из моего весеннего приложения. я пытаюсь работать с примером приложения twitter, упомянутым в ссылке sdn-twitter-graph

Но это не удается с исключением ниже

`
Caused by: java.lang.NullPointerException
    at org.neo4j.rest.graphdb.ExecutingRestRequest.uriWithoutSlash(ExecutingRestRequest.java:78)
    at org.neo4j.rest.graphdb.ExecutingRestRequest.<init>(ExecutingRestRequest.java:72)
    at org.neo4j.rest.graphdb.ExecutingRestRequest.with(ExecutingRestRequest.java:149)
    at org.neo4j.rest.graphdb.entity.RestEntity.<init>(RestEntity.java:52)
    at org.neo4j.rest.graphdb.entity.RestNode.<init>(RestNode.java:47)
    at org.neo4j.rest.graphdb.RestAPI.getReferenceNode(RestAPI.java:168)
    at org.neo4j.rest.graphdb.RestGraphDatabase.getReferenceNode(RestGraphDatabase.java:67)
    at org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory.isAlreadySubRef(TypeRepresentationStrategyFactory.java:71)
    at org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory.chooseStrategy(TypeRepresentationStrategyFactory.java:56)
    at org.springframework.data.neo4j.support.typerepresentation.TypeRepresentationStrategyFactory.<init>(TypeRepresentationStrategyFactory.java:40)
    at org.springframework.data.neo4j.config.Neo4jConfiguration.typeRepresentationStrategyFactory(Neo4jConfiguration.java:151)
    at org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$c7a98d47.CGLIB$typeRepresentationStrategyFactory$9(<generated>)
    at org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$c7a98d47$$FastClassByCGLIB$$d6c07f8a.invoke(<generated>)
    at net.sf.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:215)
    at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:285)
    at org.springframework.data.neo4j.config.Neo4jConfiguration$$EnhancerByCGLIB$$c7a98d47.typeRepresentationStrategyFactory(<generated>)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:160)
    ... 82 more
`

POM конфиг.

    <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    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>
    <groupId>com.test.spring.neo4j</groupId>
    <artifactId>TestSpringWithNeo4j</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <dependencies>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-neo4j</artifactId>
            <version>2.2.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.social</groupId>
            <artifactId>spring-social-twitter</artifactId>
            <version>1.0.5.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j</artifactId>
            <version>1.8.M06</version>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>3.1.0.RELEASE</version>
        </dependency>
        <!-- <dependency> <groupId>cglib</groupId> <artifactId>cglib</artifactId> 
            <version>3.0</version> </dependency> -->
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-neo4j-rest</artifactId>
            <version>2.0.0.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>cglib</groupId>
            <artifactId>cglib</artifactId>
            <version>2.2</version>
        </dependency>
                <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
        </dependency>
    </dependencies>
    <repositories>
        <repository>
            <id>spring</id>
            <url>http://repo.springsource.org/libs-milestone</url>
        </repository>
        <repository>
            <id>neo4j</id>
            <url>http://m2.neo4j.org/content/repositories/releases/org/neo4j/neo4j-cypher-dsl/1.9.M04/</url>
        </repository>
    </repositories>
 </project>

TwitterGraph-server.xml

    <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:neo4j="http://www.springframework.org/schema/data/neo4j" 
    xmlns:tx="http://www.springframework.org/schema/tx" 
    xmlns:context="http://www.springframework.org/schema/context"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
        http://www.springframework.org/schema/beans/spring-beans-3.0.xsd   
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd
        http://www.springframework.org/schema/data/neo4j
        http://www.springframework.org/schema/data/neo4j/spring-neo4j-2.0.xsd 
        http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

    <context:component-scan base-package="com.test.spring.services"/>
    <context:annotation-config/>

    <neo4j:repositories base-package="com.test.spring.repositories"/>
    <tx:annotation-driven mode="proxy"/>

    <bean id="graphDatabaseService"
          class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
         <constructor-arg value="http://localhost:7474/db/data" />
    </bean>

    <neo4j:config graphDatabaseService="graphDatabaseService"/>

</beans>

Пожалуйста, помогите мне с настройкой.

Благодарность..

0
user3169084 7 Янв 2014 в 16:37

2 ответа

Лучший ответ

Затем вы должны использовать Neo4j 1.8 в качестве сервера, поскольку ваша зависимость SDN также предназначена для 1.8.

Или дождитесь SDN 3.0.M2, нацеленного на Neo4j 2.0.

SDN 3.0 M1 все еще находится на уровне 2.0.0-M06

1
Michael Hunger 8 Янв 2014 в 02:28

Измените косую черту в конце URL-адреса вашего экземпляра:

<bean id="graphDatabaseService"
      class="org.springframework.data.neo4j.rest.SpringRestGraphDatabase">
     <constructor-arg value="http://localhost:7474/db/data/" />  <!-- note slash at the end -->
</bean>
0
Stefan Armbruster 7 Янв 2014 в 14:42