2

I get this error from Spring Boot.

Could not deduce driver to use based on URI 'bolt://localhost:7687

when attempting to configure with properties, or env variable

spring.data.neo4j.uri=bolt://localhost:7687

I did add the driver

   <dependency>
        <scope>runtime</scope>
        <groupId>org.neo4j</groupId>
        <artifactId>neo4j-ogm-bolt-driver</artifactId>
        <version>${neo4j-ogm.version}</version>
    </dependency>

I imagine spring boot doesn't support autoconfiguration for this yet

How can I set this driver up manually to work with Spring Boot / Data? please provide an example.

Luanne
  • 19,145
  • 1
  • 39
  • 51
xenoterracide
  • 16,274
  • 24
  • 118
  • 243
  • This app seems to show neo4j-ogm + spring boot (though using Groovy), so looks like it's supported. https://github.com/neo4j-examples/neo4j-ogm-university/tree/2.0 – icyrock.com Aug 19 '16 at 04:05
  • @icyrock.com https://github.com/neo4j-examples/neo4j-ogm-university/blob/2.0/src/main/resources/ogm.properties looks like it's using http and those aren't spring boot properties, but it might be a way to do it – xenoterracide Aug 19 '16 at 04:37

2 Answers2

5

The current Spring Boot starter for Neo4j does not detect the bolt protocol and so cannot autoconfigure the Bolt driver. However, if you supply a Configuration bean in your application context, Spring Boot will use that, and not attempt to autoconfigure the driver itself.

This should be enough to get you going:

@Bean
public Configuration getConfiguration() {
   Configuration config = new Configuration();
   config
       .driverConfiguration()
       .setURI("bolt://localhost");
   return config;
}

Note that you don't need to declare the driver name in the configuration, it will be autodetected from the URI.

Also, note the Configuration class is actually org.neo4j.ogm.config.Configuration, which you'll probably need to use explicitly.

Vince
  • 2,181
  • 13
  • 16
-1

Note that you don't need to declare the driver name in the configuration, it will be autodetected from the URI.

I'm getting 'unknown protocol: bolt' in this case.

Problem is that DriverConfiguration.setURI() will try to instantiate java.net.URL to retrieve userName, password and to set driver. I think it is better to use java.net.URI because we don't need to open connection, but only to get info.

Check this post: why does java's URL class not recognize certain protocols?

Community
  • 1
  • 1