You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Sep 1, 2023. It is now read-only.
The manual contains descriptions of all examples, which you'll find in the project source directory under https://github.com/neo4j/neo4j-java-driver-spring-boot-starter/tree/master/examples[examples].
Copy file name to clipboardExpand all lines: docs/examples/index.adoc
+16-12Lines changed: 16 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
+
:leveloffset: +1
2
+
[[examples]]
1
3
= Examples
2
-
:sectanchors:
3
-
ifndef::manualIncludeDir[]
4
-
:manualIncludeDir: ../
5
-
endif::[]
4
+
5
+
== Introduction
6
6
7
7
We provide several examples how to use this starter.
8
8
The reactive demo can only be used with Neo4j version 4.
@@ -42,7 +42,7 @@ public class SimpleApplication {
42
42
To make playing with the examples a bit easier, we have support for https://code.visualstudio.com/docs/remote/remote-overview[VS Code Remote Development].
43
43
Please follow the instructions at the link above for setting up your Visual Studio Code environment.
44
44
45
-
You can open `web`, `reactive-web` and `simple` in Visual Studio Code and let it build the container.
45
+
You can open `web`, `reactive-web` and `simple` in Visual Studio Code and let it build the container.
46
46
The development container will contain a Neo4j 4.0 database as well as the example project.
47
47
The database can be reached under http://localhost:7474[http://localhost:7474] with the username / password combination `neo4j/secret`.
48
48
@@ -51,12 +51,6 @@ The example than can be build and run via Visual Studios support for Spring Boot
51
51
The web examples are reachable on http://localhost:8080[http://localhost:8080] from both outside and inside Visual Studio Code.
52
52
Any changes to the code will be automatically reloaded and available.
* [*] _You want to work directly with a 4.0 driver?_
41
-
The starter is for you.
42
-
* [*] _You want Spring Data Neo4j⚡️RX repositories?_
43
-
The automatic configuration for SDN-RX is dependent on this starter, so it is already there and you would use exactly
44
-
the same as described in this manual to configure your connection
45
-
* [*] _You have the previous generation of Spring Data Neo4j or Neo4j-OGM?_
46
-
While you cannot use the 4.0.x line of this starter, as Spring Data Neo4j + OGM is based on the previous generation of the Java driver,
47
-
you can use the 1.7.x line of this starter. This configures a bean of the previous generation of the Neo4j driver and
48
-
also configures Neo4j-OGM to use that bean instead of an internal one.
49
-
50
-
=== Does it work with the 1.7 series of the driver?
51
-
52
-
The 1.7.x line of the starter is for the 1.7.x line of the driver, the 4.0.x line for the 4.0..x of the driver.
53
-
54
-
=== Does it work with the embedded database?
55
-
56
-
No.
57
-
58
-
=== What's with the long name?
59
-
60
-
`neo4j-java-driver-spring-boot-starter` is quite a long name for a module, we get that.
61
-
However, it follows the official Spring Boot convention described https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-auto-configuration.html#boot-features-custom-starter-naming[here].
62
-
63
-
> As a rule of thumb, you should name a combined module after the starter. For example, assume that you are creating a starter for "acme" and that you name the auto-configure module acme-spring-boot-autoconfigure and the starter acme-spring-boot-starter. If you only have one module that combines the two, name it acme-spring-boot-starter.
64
-
65
-
Our "acme" module is the Neo4j Java Driver, project name `neo4j-java-driver` and things add up from there, that's all.
66
-
67
-
== Getting started
1
+
[[manual-getting-started]]
2
+
= Getting started
68
3
69
4
As with any other Spring Boot starter, the only thing you have to do is to include the starter module via your dependency management.
70
5
If you don't configure anything, than the starter assumes `bolt://localhost:7687` as Neo4j URI and a server that has disabled authentication.
@@ -85,7 +20,7 @@ The reactive programming model however requires a 4.0 Neo4j server on the databa
85
20
To make the following intro as accessible as possible, we only display the blocking database access.
86
21
Have a look at the {gh_base}/tree/master/examples[examples directory] for a reactive web application example.
87
22
88
-
=== Preparing the database
23
+
== Preparing the database
89
24
90
25
For this example, we stay within the https://neo4j.com/developer/movie-database/[movie graph],
91
26
as it comes for free with every Neo4j instance.
@@ -104,7 +39,7 @@ At first visit, you have to change your password. We chose `secret` in the exam
104
39
Note the command ready to run in the prompt.
105
40
Execute it to fill your database with some test data.
106
41
107
-
=== Create a new Spring Boot project
42
+
== Create a new Spring Boot project
108
43
109
44
The easiest way to setup a Spring Boot project is https://start.spring.io[start.spring.io]
110
45
(which is integrated in the major IDEs as well, in case you don't want to use the website).
@@ -115,7 +50,7 @@ with all the files and settings in place for the selected build tool.
115
50
116
51
WARNING: Don't choose Spring Data Neo4j here, as it will get you the previous generation of Spring Data Neo4j including OGM and additional abstraction over the driver.
117
52
118
-
==== Maven
53
+
=== Maven
119
54
120
55
You can issue a CURL request against the Spring Initializer to create a basic Maven project:
121
56
@@ -146,7 +81,7 @@ As this starter is not yet on the initializer, you'll have to add the following
146
81
147
82
You would also add the dependency manually in case of an existing project.
148
83
149
-
==== Gradle
84
+
=== Gradle
150
85
151
86
The idea is the same, just generate a Gradle project:
152
87
@@ -174,7 +109,7 @@ dependencies {
174
109
175
110
You would also add the dependency manually in case of an existing project.
176
111
177
-
==== Configuration
112
+
=== Configuration
178
113
179
114
Now open any of those projects in your favorite IDE.
180
115
Find `application.properties` and configure your Neo4j credentials:
@@ -198,7 +133,7 @@ NOTE: It is not necessary to add any programmatically configuration of the drive
198
133
While it may work, we strongly discourage and don't support additional, pragmatical configuration of the Neo4j driver when using this starter.
199
134
200
135
201
-
==== Example CRUD Controller
136
+
=== Example CRUD Controller
202
137
203
138
Add the following `@RESTController` to your application:
204
139
@@ -294,7 +229,7 @@ dependencies {
294
229
295
230
We support both the https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-endpoints.html#production-ready-health[health-] and https://docs.spring.io/spring-boot/docs/current/reference/html/production-ready-metrics.html[metrics-actuator].
296
231
297
-
=== Health information
232
+
== Health information
298
233
299
234
Both reactive and imperative health checks are available,
300
235
with the reactive health checks having precedence when Project Reactor is detected.
@@ -332,7 +267,7 @@ In case no instance is reachable, the status will be `DOWN` and the details carr
332
267
333
268
To disable the Neo4j health indicator, use the standard Spring Boot property `management.health.neo4j.enabled` with a value of `false`.
334
269
335
-
=== Driver metrics
270
+
== Driver metrics
336
271
337
272
`neo4j-java-driver-spring-boot-starter` comes with support for https://micrometer.io[Micrometer metrics] out of the box.
338
273
It detects Micrometer on the classpath and binds the metrics of all instances of `org.neo4j.driver.Driver`, that have enabled their metrics, to a micrometer registry.
@@ -351,9 +286,3 @@ The following metrics are exposes
351
286
352
287
All metrics will have the tags `name` (the bean of the driver they belong to)
353
288
and `poolId` (the id of the connection pool, that contributed to the corresponding counter or gauge).
* [*] _You want to work directly with a 4.0 driver?_
28
+
The starter is for you.
29
+
* [*] _You want Spring Data Neo4j⚡️RX repositories?_
30
+
The automatic configuration for SDN-RX is dependent on this starter, so it is already there and you would use exactly
31
+
the same as described in this manual to configure your connection
32
+
* [*] _You have the previous generation of Spring Data Neo4j or Neo4j-OGM?_
33
+
While you cannot use the 4.0.x line of this starter, as Spring Data Neo4j + OGM is based on the previous generation of the Java driver,
34
+
you can use the 1.7.x line of this starter. This configures a bean of the previous generation of the Neo4j driver and
35
+
also configures Neo4j-OGM to use that bean instead of an internal one.
36
+
37
+
== Does it work with the 1.7 series of the driver?
38
+
39
+
The 1.7.x line of the starter is for the 1.7.x line of the driver, the 4.0.x line for the 4.0..x of the driver.
40
+
41
+
== Does it work with the embedded database?
42
+
43
+
No.
44
+
45
+
== What's with the long name?
46
+
47
+
`neo4j-java-driver-spring-boot-starter` is quite a long name for a module, we get that.
48
+
However, it follows the official Spring Boot convention described https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-developing-auto-configuration.html#boot-features-custom-starter-naming[here].
49
+
50
+
> As a rule of thumb, you should name a combined module after the starter. For example, assume that you are creating a starter for "acme" and that you name the auto-configure module acme-spring-boot-autoconfigure and the starter acme-spring-boot-starter. If you only have one module that combines the two, name it acme-spring-boot-starter.
51
+
52
+
Our "acme" module is the Neo4j Java Driver, project name `neo4j-java-driver` and things add up from there, that's all.
The current Spring Boot starter you get on https://start.spring.io/#!type=maven-project&language=java&platformVersion=2.2.5.RELEASE&packaging=jar&jvmVersion=1.8&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=data-neo4j[start.spring.io] recognizes the driver bean created by this starter here.
4
+
That means you can add this starter via `{groupId}:{artifactId}:{neo4j-java-driver-spring-boot-starter_version}` and use the properties under `{config_prefix}` to configure the connection.
5
+
Thus you don't have to work your way into Neo4j-OGM to manipulate the encapsulated driver but inject a correctly configured driver bean into the Neo4j-OGM session factory.
0 commit comments