如何将 Bolt 驱动程序与 Spring Boot/Data Neo4j 一起使用
How can I use the Bolt driver with Spring Boot/Data Neo4j
我从 Spring 引导中得到这个错误。
Could not deduce driver to use based on URI 'bolt://localhost:7687
尝试使用属性或环境变量进行配置时
spring.data.neo4j.uri=bolt://localhost:7687
我确实添加了驱动程序
<dependency>
<scope>runtime</scope>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-bolt-driver</artifactId>
<version>${neo4j-ogm.version}</version>
</dependency>
我imagine spring boot doesn't support autoconfiguration for this yet
如何手动设置此驱动程序以使用 Spring 启动/数据?请举个例子。
Neo4j 的当前 Spring 启动器不检测 bolt
协议,因此无法自动配置 Bolt 驱动程序。但是,如果您在应用程序上下文中提供配置 bean,Spring Boot 将使用它,并且不会尝试自动配置驱动程序本身。
这应该足以让你继续:
@Bean
public Configuration getConfiguration() {
Configuration config = new Configuration();
config
.driverConfiguration()
.setURI("bolt://localhost");
return config;
}
请注意,您无需在配置中声明驱动程序名称,它会从 URI 中自动检测到。
此外,请注意 Configuration
class 实际上是 org.neo4j.ogm.config.Configuration
,您可能需要明确使用它。
请注意,您无需在配置中声明驱动程序名称,它将自动从 URI 中检测到。
在这种情况下,我收到“未知协议:bolt”。
问题是 DriverConfiguration.setURI()
将尝试实例化 java.net.URL
以检索 userName
、password
并设置驱动程序。我认为使用 java.net.URI
更好,因为我们不需要打开连接,而只是获取信息。
检查此 post:
why does java's URL class not recognize certain protocols?
我从 Spring 引导中得到这个错误。
Could not deduce driver to use based on URI 'bolt://localhost:7687
尝试使用属性或环境变量进行配置时
spring.data.neo4j.uri=bolt://localhost:7687
我确实添加了驱动程序
<dependency>
<scope>runtime</scope>
<groupId>org.neo4j</groupId>
<artifactId>neo4j-ogm-bolt-driver</artifactId>
<version>${neo4j-ogm.version}</version>
</dependency>
我imagine spring boot doesn't support autoconfiguration for this yet
如何手动设置此驱动程序以使用 Spring 启动/数据?请举个例子。
Neo4j 的当前 Spring 启动器不检测 bolt
协议,因此无法自动配置 Bolt 驱动程序。但是,如果您在应用程序上下文中提供配置 bean,Spring Boot 将使用它,并且不会尝试自动配置驱动程序本身。
这应该足以让你继续:
@Bean
public Configuration getConfiguration() {
Configuration config = new Configuration();
config
.driverConfiguration()
.setURI("bolt://localhost");
return config;
}
请注意,您无需在配置中声明驱动程序名称,它会从 URI 中自动检测到。
此外,请注意 Configuration
class 实际上是 org.neo4j.ogm.config.Configuration
,您可能需要明确使用它。
请注意,您无需在配置中声明驱动程序名称,它将自动从 URI 中检测到。
在这种情况下,我收到“未知协议:bolt”。
问题是 DriverConfiguration.setURI()
将尝试实例化 java.net.URL
以检索 userName
、password
并设置驱动程序。我认为使用 java.net.URI
更好,因为我们不需要打开连接,而只是获取信息。
检查此 post: why does java's URL class not recognize certain protocols?