"This syntax is no longer supported (missing properties are now returned as null)" when running SpringRestGraphDatabase

StackOverflow https://stackoverflow.com/questions/21442040

  •  04-10-2022
  •  | 
  •  

質問

I've take the sample application "gs-accessing-data-neo4j" and tried customising it to use the Rest Server.

I've managed to get it up and running and can see data going into the database but I'm getting the following error:

"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"

I suspect it might be because of a mismatch between dependencies in my POM but I've checked and double checked and as far as I can tell it should be OK:

<?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>

This is the customised Application.java I'm using to run the sample, all I've basically changed from the sample app is the reference to 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);
}

}

Any help or pointers greatly received!!!

役に立ちましたか?

解決

You're suffering from a version conflict here.

The version of Spring Data Neo4j you're using (2.3.3) is supposed to work against a Neo4j 1.9.x.

Spring Data Neo4j 3.0 will be compliant with Neo4j 2.0.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top