单独Neo4j工程运行好好的,准备加到已有的Springboot工程,但只引用spring-boot-starter-data-neo4j包一启动就报null错误,具体报错信息如下:
Caused by: java.lang.NullPointerException
at org.neo4j.ogm.metadata.DomainInfo.registerDefaultFieldConverters(DomainInfo.java:333) ~[neo4j-ogm-core-3.1.0.jar:3.1.0]
at org.neo4j.ogm.metadata.DomainInfo.postProcessFields(DomainInfo.java:241) ~[neo4j-ogm-core-3.1.0.jar:3.1.0]
at org.neo4j.ogm.metadata.DomainInfo.finish(DomainInfo.java:209) ~[neo4j-ogm-core-3.1.0.jar:3.1.0]
at org.neo4j.ogm.metadata.DomainInfo.create(DomainInfo.java:119) ~[neo4j-ogm-core-3.1.0.jar:3.1.0]
at org.neo4j.ogm.metadata.MetaData.<init>(MetaData.java:46) ~[neo4j-ogm-core-3.1.0.jar:3.1.0]
at org.neo4j.ogm.session.SessionFactory.<init>(SessionFactory.java:80) ~[neo4j-ogm-core-3.1.0.jar:3.1.0]
at org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration.sessionFactory(Neo4jDataAutoConfiguration.java:75) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$$EnhancerBySpringCGLIB$$40719632.CGLIB$sessionFactory$1(<generated>) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$$EnhancerBySpringCGLIB$$40719632$$FastClassBySpringCGLIB$$f148cce4.invoke(<generated>) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at org.springframework.cglib.proxy.MethodProxy.invokeSuper(MethodProxy.java:228) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.context.annotation.ConfigurationClassEnhancer$BeanMethodInterceptor.intercept(ConfigurationClassEnhancer.java:361) ~[spring-context-5.0.8.RELEASE.jar:5.0.8.RELEASE]
at org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration$$EnhancerBySpringCGLIB$$40719632.sessionFactory(<generated>) ~[spring-boot-autoconfigure-2.0.4.RELEASE.jar:2.0.4.RELEASE]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_192]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[?:1.8.0_192]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_192]
at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_192]
经过一轮删减排查,发现原有类的代码定义List data;修改为 List<?> data,同时getter,setter也要修改,这样重新启动就可以解决。