我正在使用包含Neo4j数据库的Spring MVC(4.2.0.RELEASE)开发Java Rest服务。因此使用Spring Data Neo4j(4.1.1.RELEASE)。
SDN配置如下所示:
@Configuration
@ComponentScan(basePackages = { "com.xxx.yyy" })
@EnableNeo4jRepositories(basePackages = "com.xxx.yyy.dao.repo")
@EnableTransactionManagement
public class Neo4jConfig extends Neo4jConfiguration {
@Autowired
private ApplicationProperties properties;
@Bean
public SessionFactory getSessionFactory() {
return new SessionFactory(getConfiguration(), "com.xxx.yyy.dao.beans");
}
@Bean
public Neo4jOperations neo4jTemplate() throws Exception {
return new Neo4jTemplate(getSession());
}
@Bean
public org.neo4j.ogm.config.Configuration getConfiguration() {
org.neo4j.ogm.config.Configuration config = new org.neo4j.ogm.config.Configuration();
config.driverConfiguration().setDriverClassName(this.properties.getNeo4jDriver())
.setURI(this.properties.getNeo4jEndpoint())
.setCredentials(this.properties.getNeo4jUser(), this.properties.getNeo4jPassword());
return config;
}
@Bean
@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS)
public Session getSession() throws Exception {
return super.getSession();
}
}
应用程序部署在生产环境中的Tomcat7上。如果只部署了一个版本的应用程序并且没有填写版本标志,那么一切都像魅力一样。
对于零停机部署,我想使用tomcat上的version标志来部署多个版本。如果我这样做,由于NullPointerException
中的org.neo4j.ogm.context.RestModelMapper
,应用程序将无法运行。
堆栈跟踪:
java.lang.NullPointerException
at org.neo4j.ogm.context.RestModelMapper.mapEntity(RestModelMapper.java:153) ~[neo4j-ogm-core-2.0.1.jar:?]
at org.neo4j.ogm.context.RestModelMapper.map(RestModelMapper.java:76) ~[neo4j-ogm-core-2.0.1.jar:?]
at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:94) ~[neo4j-ogm-core-2.0.1.jar:?]
at org.neo4j.ogm.session.delegates.ExecuteQueriesDelegate.query(ExecuteQueriesDelegate.java:73) ~[neo4j-ogm-core-2.0.1.jar:?]
at org.neo4j.ogm.session.Neo4jSession.query(Neo4jSession.java:313) ~[neo4j-ogm-core-2.0.1.jar:?]
仅当我在tomcat上使用版本标志时才会出现此问题。有人知道这里有什么问题吗?
答案 0 :(得分:0)
我终于通过更改OGM HTTP驱动程序的版本和Spring Data Neo4j依赖项来解决了这个问题。
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-neo4j</artifactId>
<version>4.1.4.RELEASE</version>
</dependency>
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-http-driver</artifactId>
<version>2.0.5</version>
</dependency>
使用此设置,Tomcat版本标志https://tomcat.apache.org/tomcat-7.0-doc/config/context.html的部署现在正在运行。