"不再支持此语法(缺少的属性现在返回为null)"运行SpringRestGraphDatabase时

时间:2014-01-29 20:33:49

标签: java neo4j spring-data-neo4j

我采用示例应用程序“gs-access-data-neo4j”并尝试自定义它以使用Rest服务器。

我已经设法启动并运行并且可以看到数据进入数据库但是我收到以下错误:

"Caused by: org.neo4j.rest.graphdb.RestResultException: This syntax is no longer supported       (missing properties are now returned as null). (line 1, column 72)
"START `person`=node:__types__(className="hello.Person") WHERE `person`.`name`! = {0} RETURN `person`"
                                                                        ^ at"

我怀疑这可能是因为我的POM中的依赖项不匹配但是我已经检查并仔细检查过,据我所知它应该没问题:

<?xml version="1.0" encoding="UTF-8"?>
<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>org.springframework</groupId>
    <artifactId>gs-accessing-data-neo4j</artifactId>
    <version>0.1.0</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>0.5.0.M6</version>
    </parent>

    <dependencies>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-neo4j-rest</artifactId>
            <version>2.3.3.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>org.neo4j</groupId>
            <artifactId>neo4j</artifactId> 
            <version>2.0.0-M06</version>
        </dependency> 
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-context</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-tx</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.data</groupId>
            <artifactId>spring-data-neo4j</artifactId>
            <version>2.3.3.RELEASE</version>
        <!-- 
            <exclusions>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-tx</artifactId>
                </exclusion>
                <exclusion>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-aspects</artifactId>
                </exclusion>
            </exclusions>
        -->
        </dependency>
        <dependency>
            <groupId>javax.validation</groupId>
            <artifactId>validation-api</artifactId>
            <version>1.0.0.GA</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
            </plugin>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

    <repositories>
        <repository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>http://repo.spring.io/libs-milestone</url>
        </repository>
        <repository>
            <id>neo4j-release-repository</id>
            <name>Neo4j Maven 2 release repository</name>
            <url>http://m2.neo4j.org/content/repositories/releases/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

    <pluginRepositories>
        <pluginRepository>
            <id>spring-milestones</id>
            <name>Spring Milestones</name>
            <url>http://repo.spring.io/libs-milestone</url>
        </pluginRepository>
    </pluginRepositories>

</project>

这是我用来运行示例的自定义Application.java,我基本上从示例应用程序中更改了对SpringRestGraphDatabase的引用:

package hello;

import java.io.File;

import org.neo4j.graphdb.Transaction;
import org.neo4j.kernel.EmbeddedGraphDatabase;
import org.neo4j.kernel.impl.util.FileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.neo4j.config.EnableNeo4jRepositories;
import org.springframework.data.neo4j.config.Neo4jConfiguration;
import org.springframework.data.neo4j.core.GraphDatabase;
import org.springframework.data.neo4j.rest.SpringRestGraphDatabase;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;


@Configuration
@EnableNeo4jRepositories
public class Application extends Neo4jConfiguration implements CommandLineRunner {

//    @Bean
//    EmbeddedGraphDatabase graphDatabaseService() {
//        return new EmbeddedGraphDatabase("accessingdataneo4j.db");
//    }


@Bean
SpringRestGraphDatabase graphDatabaseService() {
    return new SpringRestGraphDatabase("http://localhost:7474/db/data");
}


@Autowired
PersonRepository personRepository;

@Autowired
GraphDatabase graphDatabase;

public void run(String... args) throws Exception {
    Person greg = new Person("Greg");
    Person roy = new Person("Roy");
    Person craig = new Person("Craig");

    System.out.println("Before linking up with Neo4j...");
    for (Person person : new Person[]{greg, roy, craig}) {
        System.out.println(person);
    }

    Transaction tx = graphDatabase.beginTx();
    try {
        personRepository.save(greg);
        personRepository.save(roy);
        personRepository.save(craig);

        greg = personRepository.findByName(greg.name);
        greg.worksWith(roy);
        greg.worksWith(craig);
        personRepository.save(greg);

        roy = personRepository.findByName(roy.name);
        roy.worksWith(craig);
        // We already know that roy works with greg
        personRepository.save(roy);

        // We already know craig works with roy and greg

        tx.success();
    } finally {
        tx.finish();
    }

    System.out.println("Lookup each person by name...");
    for (String name: new String[]{greg.name, roy.name, craig.name}) {
        System.out.println(personRepository.findByName(name));
    }

    System.out.println("Looking up who works with Greg...");
    for (Person person : personRepository.findByTeammatesName("Greg")) {
        System.out.println(person.name + " works with Greg.");
    }
}

public static void main(String[] args) throws Exception {
    FileUtils.deleteRecursively(new File("accessingdataneo4j.db"));

    SpringApplication.run(Application.class, args);
}

}

任何帮助或指示都很受欢迎!!!

1 个答案:

答案 0 :(得分:2)

你在这里遇到版本冲突。

您正在使用的Spring Data Neo4j版本(2.3.3)应该可以对抗Neo4j 1.9.x.

Spring Data Neo4j 3.0将符合Neo4j 2.0。