Comments (5)
Thanks for reporting this here.
A concrete instance of the Neo4j 4.0 Java Driver itself has no notion of a default database.
That information is tied to a session. Have a look here regarding the relations between them:
https://speakerdeck.com/michaelsimons/reactive-transactions-masterclass?slide=113
So it makes no sense to expose that as a property to the starter: The starter should only configure the driver with the stuff the driver exposes as configuration. As there is no default session to configure on the driver, we don't do this.
But at least address that with Neo4j-OGM: In OGM we can configure a default database and we provide an option for that for the Bolt transport since OGM 3.2.6.
Solution for your issue with OGM 3.2.6
Regarding your configuration @SledgeHammer01, there are some issues:
You have added both Spring Data Neo4j (SDN) starter and this starter. That works and is supported. See this example https://github.com/neo4j/neo4j-java-driver-spring-boot-starter/tree/master/examples/ogm-integration
However, you're configuring SDN + OGM manually, that is you are creating a 2nd instance of the BoltDriver by return new SessionFactory(configuration(), "org.xxx.yyy.movies.models");
and related. In fact, if you don't want to configure anything else, you don't need any of that. Just configure the package scanning with the annotation. That is enough.
If you want to configure the database, please do the following:
- Remove the dependency to this starter, keep SDN starter. The later uses the latest Bolt Driver (4.0), too.
- In your build file (
pom.xml
) add the following property:<neo4j-ogm.version>3.2.6</neo4j-ogm.version>
(it is been released to central as of writing, could be a moment until it's there - In your configuration method above do the following
package com.example.thing;
import org.neo4j.ogm.config.Configuration.Builder;
import org.springframework.boot.autoconfigure.data.neo4j.Neo4jProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class Neo4jOGMConfiguration {
@Bean
public org.neo4j.ogm.config.Configuration ogmConfiguration(Neo4jProperties properties) {
return new Builder().uri(properties.getUri())
.credentials(properties.getUsername(), properties.getPassword())
.database("system")
.verifyConnection(true)
.build();
}
}
That's enough. Be aware that this configuration uses different properties:
spring.data.neo4j.username=neo4j
spring.data.neo4j.password=secret
spring.data.neo4j.uri=bolt://localhost:7687
I have attached a working MVP:
thing.zip
General rule of the thumb: Go for the least amount of config in Spring Boot.
Anyway: If you add additional configuration to Neo4j-OGM as part of Spring Data Neo4j, you won't need this separate driver starter. This starter here exists for 2 reasons:
- Help people that don't want to use Spring Data Neo4j and an object mapper (Neo4j-OGM)
- It integrates with Neo4j-OGM for all people, that want to configure only the Bolt driver of OGM.
Hope that helps and thanks again for your report.
from neo4j-java-driver-spring-boot-starter.
Thanks for your feedback! Please check your Spring Boot version, 2.2.2 should treat this correctly (as in my example). If not, please open an issue over there.
from neo4j-java-driver-spring-boot-starter.
Well, this seems merely connected with applying spring JPA configuration and extension capabilities. I didn't test this yet, but would take the essence of the two articles cited below as a starting point:
- provide with a configuration pojo bean for each datasource (as of spring-boot-2.2.0, the annotation @ConfigurationProperties suffices)
- translate how the ORM @table annotation from the description translates towards an OGM analogy (I don't know yet, but assume a rather simple solution)
- provide with an EMF per data source
- if inter datasource transactional behavior is required, provide with a transaction manager implementation per datasource
references
spring ORM multi datasource approach as example
spring boot configuration detailed
Have fun!
from neo4j-java-driver-spring-boot-starter.
Well, this seems merely connected with applying spring JPA configuration and extension capabilities. I didn't test this yet, but would take the essence of the two articles cited below as a starting point:
- provide with a configuration pojo bean for each datasource (as of spring-boot-2.2.0, the annotation @ConfigurationProperties suffices)
- translate how the ORM @table annotation from the description translates towards an OGM analogy (I don't know yet, but assume a rather simple solution)
- provide with an EMF per data source
- if inter datasource transactional behavior is required, provide with a transaction manager implementation per datasource
references
spring ORM multi datasource approach as examplespring boot configuration detailed
Have fun!
Not instances... in the new 4.0 version, you can have multiple databases on the same instance, so there needs to be a way to specify which. I think the functionality is exposed in the latest driver, it has to trickle up to the Spring Starter.
from neo4j-java-driver-spring-boot-starter.
I removed the quote (ms)
Thanks, the new property enabled the .database() property! I have two databases in my 4.0 install, so I needed my own custom properties as I have different credentials for each. If I remove the sessionFactory and the transactionManager, I can't run the app as it complains about a missing sessionFactory bean when I try to auto-wire the repo. That's fine, I can leave them in. My main thing was the .database(). Thanks again.
from neo4j-java-driver-spring-boot-starter.
Related Issues (17)
- Configure logging to go through spring-jcl HOT 1
- Update license header.
- Remove default value for required uri property.
- Advanced bolt: and neo4j: schemes cannot be used with the starter.
- Driver works with embedded (if BOLT is configured)
- Error when connecting to Neo4J using the Java driver HOT 2
- Neo4jHealthIndicator: Use read transaction instead of the session to execute the cypher query HOT 1
- Neo4jDriverProperties class is missing HOT 1
- Adding neo4j-java-driver-spring-boot-starter prevents Spring Boot app from graceful shutdown HOT 7
- Run tests against the experimental Neo4j 4.0 docker image.
- Cannot coerce STRING to LocalDate HOT 2
- Support for neo4j 5.x HOT 1
- Update and Delete operation in spring boot Neo4j doesn't work like JPA
- saveAll batch size dynamic configuration
- Upgrade test harness Examples to Neo4j 4.0 test harness.
- Provide VS code devcontainer for reactive web example.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neo4j-java-driver-spring-boot-starter.