我在Kotlin中有一个Spring boot项目,使用Neo4j 3.3.5作为嵌入式数据库。数据库被测试为可访问(读写)。我现在想使用neo4j desktop 1.0.24将数据库作为远程数据库访问,以便以图形方式查看节点,并可能在外部添加我自己的节点。
我目前使用以下命令访问数据库:
private val curdir = System.getProperty("user.dir")
val graphDb: GraphDatabaseService = GraphDatabaseFactory().newEmbeddedDatabase(File("${curdir}/database"))
我找到的最新指南是this。
简而言之,上面指南中提供的配置是:
GraphDatabaseService db = new GraphDatabaseFactory().newEmbeddedDatabaseBuilder(DB_DIR)
.setConfig(ShellSettings.remote_shell_enabled, "true")
.setConfig(ShellSettings.remote_shell_port, "5555")
.newGraphDatabase();
但是这似乎不起作用(未解析的引用ShellSettings)。
在对当前的(3.3)文档进行了一些搜索之后,我发现setConfig
有3种风格,其中有两种已经被弃用:
setConfig(Map<String,String> config) // deprecated
setConfig(String name, String value) // deprecated
setConfig(Setting<?> setting, String value)
最后一个选项不是,而是interface Setting<T>
本身,它正在等待重构,也已被弃用。
尝试像这样使用setConfig,例如:
var graphDb = GraphDatabaseFactory().newEmbeddedDatabaseBuilder(File("${curdir}/database"))
.setConfig("remote_shell_enabled", "true")
.setConfig("remote_shell_port", "5555")
.newGraphDatabase()
虽然适用于Spring,但不能通过以下配置从neo4j桌面访问:
Database Name: Database
Host: localhost
Bolt Port: 5555
username: blank
password: blank
我还能尝试什么呢?
发布于 2018-05-08 19:24:56
台式机使用的不是shell
,而是bolt protocol
。因此您需要在配置中启用它:
GraphDatabaseSettings.BoltConnector bolt = GraphDatabaseSettings.boltConnector( "0" );
GraphDatabaseService graphDb = new GraphDatabaseFactory()
.newEmbeddedDatabaseBuilder( DB_PATH )
.setConfig( bolt.type, "BOLT" )
.setConfig( bolt.enabled, "true" )
.setConfig( bolt.address, "localhost:7687" )
.newGraphDatabase();
您还必须在项目中添加库:
<dependency>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-bolt</artifactId>
<version>3.3.5</version>
</dependency>
有关更多信息,请参阅文档:https://neo4j.com/docs/java-reference/current/tutorials-java-embedded/#tutorials-java-embedded-bolt
https://stackoverflow.com/questions/50219699
复制相似问题