java - 仅 GraphRepository<> 中的 findAll() 以 org.neo4j.graphdb.TransactionFailureException : Failed to mark transaction as rollback only 结尾

标签 java neo4j spring-data-neo4j

通过使用 findAll()来自GraphRepository<Account> :

    context = new ClassPathXmlApplicationContext("spring/spring-config.xml");
    accountService = (AccountService) context.getBean("accountService");

    //getAll(){return accountRepository.findAll()}

    accountService.getAll().forEach(account -> System.out.println(account));

(顺便说一句。我的 accountService 中的所有其他功能都有效)

我收到此错误:

 Exception in thread "main" org.neo4j.graphdb.TransactionFailureException: 
 Failed to mark transaction as rollback only.

我尝试通过以下方式解决问题:Spring Data Neo4J repository findAll() results in a nullpointerexception , 所以我添加<tx:annotation-driven mode="proxy"/>在我的 spring-config.xml 中 但这并不能解决我的问题。

这是我的 github 存储库:https://github.com/mzober/springContextWorld/tree/CollectorManager_ErrorBranch

这是我的 spring-config.xml:

 <beans xmlns="http://www.springframework.org/schema/beans"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xmlns:context="http://www.springframework.org/schema/context"
   xmlns:neo4j="http://www.springframework.org/schema/data/neo4j"
   xmlns:tx="http://www.springframework.org/schema/tx"
   xsi:schemaLocation=
           "http://www.springframework.org/schema/beans
   http://www.springframework.org/schema/beans/spring-beans.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.xsd
    http://www.springframework.org/schema/tx
    http://www.springframework.org/schema/tx/spring-tx.xsd">
<context:annotation-config/>
<context:spring-configured/>

<context:component-scan base-package="com.mz.springContextWorld.domain"/>
<context:component-scan base-package="com.mz.springContextWorld.repositories"/>
<context:component-scan base-package="com.mz.springContextWorld.gui.listener"/>
<context:component-scan base-package="com.mz.springContextWorld.gui.components"/>
<context:component-scan base-package="com.mz.springContextWorld.gui.creational"/>
<context:component-scan base-package="com.mz.springContextWorld.services"/>

<neo4j:config storeDirectory="target/neo4j-db-plain"
              base-package="com.mz.springContextWorld.domain"/>
<neo4j:repositories base-package="com.mz.springContextWorld.repositories"/>

<tx:annotation-driven mode="proxy"/>

如果我应该发布更多代码,请写评论。

感谢您的帮助。

最佳答案

这可能与以下问题有关:https://jira.spring.io/browse/DATAGRAPH-531 。如果是这样的话,你需要改变

service.findAll()

至:

service.findAll().as(Collection.class)

...回滚异常应该消失。

关于java - 仅 GraphRepository<> 中的 findAll() 以 org.neo4j.graphdb.TransactionFailureException : Failed to mark transaction as rollback only 结尾,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28928822/

相关文章:

java - 如何在 Neo4j 中使用 Using enum RelationshipType?

python - 找到排除特定边的最短路径?

python - 无法在 COALESCE pypher 中设置列​​表类型值

lucene - 在 Neo4j 上通过带有 html 标记的富文本进行全文搜索

java - 在没有 JUnit 的情况下运行 Cucumber 的替代方法?

java - 在 "graphView"中标签不是从原点开始

java - 在java中将int数组转换为bufferedImage

java - VideoView setVideoUri 否 Content Provider

java - 搜索具有自定义 id 的对象

java - 如何使用SDN仅在节点不存在时创建节点?