日志:
Exception
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.transaction.CannotCreateTransactionException: Could not open Neo4j Session for transaction; nested exception is java.lang.UnsupportedOperationException
org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:1013)
org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:897)
javax.servlet.http.HttpServlet.service(HttpServlet.java:634)
org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:882)
......
Root Cause
org.springframework.transaction.CannotCreateTransactionException: Could not open Neo4j Session for transaction; nested exception is java.lang.UnsupportedOperationException
org.springframework.data.neo4j.transaction.Neo4jTransactionManager.doBegin(Neo4jTransactionManager.java:203)
org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:378)
org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:474)
org.springframework.transaction.interceptor.TransactionAspectSupport.invokeWithinTransaction(TransactionAspectSupport.java:289)
org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:98)
org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
org.springframework.aop.framework.CglibAopProxy$DynamicAdvisedInterceptor.intercept(CglibAopProxy.java:688)
......
Root Cause
java.lang.UnsupportedOperationException
org.neo4j.ogm.driver.Driver.setTransactionManager(Driver.java:82)
org.neo4j.ogm.session.transaction.DefaultTransactionManager.<init>(DefaultTransactionManager.java:44)
org.neo4j.ogm.session.Neo4jSession.<init>(Neo4jSession.java:106)
org.neo4j.ogm.session.Neo4jSession.<init>(Neo4jSession.java:113)
org.neo4j.ogm.session.SessionFactory.openSession(SessionFactory.java:140)
org.springframework.data.neo4j.transaction.Neo4jTransactionManager.doBegin(Neo4jTransactionManager.java:161)
......
查看源码org.neo4j.ogm.driver.Driver.setTransactionManager,看来Driver最新3.1.6版本可能太新了,改成3.1.0就可以
/** @deprecated */
@Deprecated
default void setTransactionManager(TransactionManager tx) {
throw new UnsupportedOperationException();
}
3.1.0版本:
void setTransactionManager(TransactionManager tx);