gpt4 book ai didi

java - 运行 SpringRestGraphDatabase 时为 "This syntax is no longer supported (missing properties are now returned as null)"

转载 作者:行者123 更新时间:2023-11-30 04:03:22 25 4
gpt4 key购买 nike

我使用了示例应用程序“gs-accessing-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);
}

}

非常感谢任何帮助或指点!!!

最佳答案

您遇到了版本冲突问题。

您正在使用的 Spring Data Neo4j 版本 (2.3.3) 应该适用于 Neo4j 1.9.x。

Spring Data Neo4j 3.0 将与 Neo4j 2.0 兼容。

关于java - 运行 SpringRestGraphDatabase 时为 "This syntax is no longer supported (missing properties are now returned as null)",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21442040/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com