In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to connect multiple Neo4j databases in a Spring Boot project". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to connect multiple Neo4j databases in a Spring Boot project.
problem
I want to use different Neo4j-OGM instances in my Spring Boot application through different Neo4j session factories. I have several domains, each with its own entity class and repository, and each domain with its own instance of Neo4j. I added Spring Boot Starter Data Neo4j, but it only allows one connection, and all my repositories use it.
Solution
To do this, you need the latest version of Spring Boot 2.x and Spring Data, which is called Spring Data Lovelace (RC1). In a standard Spring Boot 2 application generated by start.spring.io, you will change the Spring Data Release series with the following properties: pom.xml
Lovelace-RELEASE
Then the solution can be broken down into two problems 1. Multiple connections to Spring Data Neo4j are provided by reusing the Neo4jProperties in Spring Boot to configure Neo4j. two。 Configure session factory for Spring Data Neo4j.
Implementation code
The following code is located in the sample projects using-multiple-session-factories/Domain1Config.java and Domain2Config.java of this article. The Spring Boot application uses the following configuration application.properties
# Configuration for entities and repositories in "domain1" spring.data.neo4j.username = neo4jspring.data.neo4j.password = domain1spring.data.neo4j.uri = bolt://localhost:7687# Configuration for entities and repositories in "domain2" spring.data.neo4j.domain2.username = neo4jspring.data.neo4j.domain2.password = domain2spring.data.neo4j.domain2.uri = bolt://localhost:7688 so far, I believe you have a better understanding of "how to connect multiple Neo4j databases in a Spring Boot project" You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.