关于java:仅GraphRepository <>中的findAll()结尾于org.neo4j.graphdb.TransactionFailureException:无法将事务标记为仅回滚

only findAll() from GraphRepository<> ends in org.neo4j.graphdb.TransactionFailureException: Failed to mark transaction as rollback only

通过使用GraphRepository<Account>中的findAll()

1
2
3
4
5
6
    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的所有其他功能都起作用)

我收到此错误:

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

我尝试使用以下方法解决问题:Spring Data Neo4J存储库findAll()导致nullpointerexception,
所以我在spring-config.xml中添加了<tx:annotation-driven mode="proxy"/>
但这不能解决我的问题。

这里是我的github仓库:https://github.com/mzober/springContextWorld/tree/CollectorManager_ErrorBranch

这是我的spring-config.xml:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 <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。如果是这样,您需要更改

1
service.findAll()

至:

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

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