我的Java程序在特定于应用程序的ogm.properties
中查找$DATA_DIR
,并加载用于构建Configuration
的{{1}}。默认SessionFactory
使用嵌入式驱动程序和指向ogm.properties
子目录的文件URI。到目前为止一切都很好。
这个想法是用户可以提供使用不同驱动程序的自己的$DATA_DIR
。因此,我无法将自定义ogm.properties
传递给GraphDatabaseService
构造函数,因为我自己不构造它。
如何将configuration options传递给嵌入式驱动程序?我尝试在EmbeddedDriver
下的不同位置放置neo4j.conf
,但似乎无法识别。
答案 0 :(得分:0)
在2018年底即将发布的Neo4j 3.1.6中,您将能够执行以下操作:
在ogm.properties
中:
# Looks in the root of the classpath
neo4j.conf.location=neo4j.conf
# Explicitly in the classpath
# neo4j.conf.location=classpath:neo4j.conf
# Or as file URL
# neo4j.conf.location=file:///config/neo4j.conf
或在Java配置中以编程方式:
String neo4jConfLocation;
// Choose one:
// Looks in the root of the classpath
neo4jConfLocation = "neo4j.conf"
// Explicitly in the classpath
// neo4jConfLocation = "classpath:neo4j.conf"
// Or as file URL
// neo4jConfLocation = "file:///config/neo4j.conf"
Configuration configuration =
new Configuration.Builder()
.neo4jConfLocation(neo4jConfLocation)
.build();
要将配置文件从文件或类路径资源传递到嵌入式实例。