之前做了neo4j可行性测试,没问题了.开始正式使用,在新generator出的microserivce里面开始整合,但是新microserivce就一直报错
原因
因为不需要 neo4j-migrations-spring-boot-starter 这个包,就没有把这个包引入进来,一开始以为是yml 或者是neo4j的问题,一直在排错,最后发现是缺少这个被传递依赖的包
<dependency>
<groupId>org.neo4j.driver</groupId>
<artifactId>neo4j-java-driver-spring-boot-starter</artifactId>
<version>${neo4j-driver.version}</version>
</dependency>
解决
org:
neo4j:
driver:
pool:
metrics-enabled: true
uri: bolt://localhost:7687
# Uncomment to use an authenticated connection
authentication:
username: neo4j
password: secret
yml配置已经检查很多遍了,真的是头都搞大了,弄了快一下午.因为microservice是公司的generator生成的,其他的整合错误的可能性基本上不存在,一直以为是yml里面哪里有问题. 直到最后实在头痛了,直接定义了一个bean
@Bean
public org.neo4j.ogm.config.Configuration getConfiguration() {
return new org.neo4j.ogm.config.Configuration.Builder().credentials("neo4j", "secret")
.uri("bolt://localhost:7687").build();
}
然后居然不报错了,这才明白是yml里面的配置根本没有生效,毕竟yml format我已经一句一句的看过了(因为yml格式很严格,一不注意就有可能有问题)
然后去一开始可行性测试的项目里去看dependency,
发现被移除的这个neo4j-migrations-spring-boot-starter包,里面还传递依赖了neo4j-java-driver-spring-boot-starter,把这个包依赖进来了之后就没问题了.