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
Copy file name to clipboardExpand all lines: README.adoc
+145-13
Original file line number
Diff line number
Diff line change
@@ -8,10 +8,12 @@ The Spring Data MongoDB project aims to provide a familiar and consistent Spring
8
8
The Spring Data MongoDB project provides integration with the MongoDB document database.
9
9
Key functional areas of Spring Data MongoDB are a POJO centric model for interacting with a MongoDB `+Document+` and easily writing a repository style data access layer.
10
10
11
+
[[code-of-conduct]]
11
12
== Code of Conduct
12
13
13
14
This project is governed by the https://github.com/spring-projects/.github/blob/e3cc2ff230d8f1dca06535aa6b5a4a23815861d4/CODE_OF_CONDUCT.md[Spring Code of Conduct]. By participating, you are expected to uphold this code of conduct. Please report unacceptable behavior to [email protected].
14
15
16
+
[[getting-started]]
15
17
== Getting Started
16
18
17
19
Here is a quick teaser of an application using Spring Data Repositories in Java:
@@ -59,6 +61,7 @@ class ApplicationConfig extends AbstractMongoClientConfiguration {
59
61
}
60
62
----
61
63
64
+
[[maven-configuration]]
62
65
=== Maven configuration
63
66
64
67
Add the Maven dependency:
@@ -68,24 +71,25 @@ Add the Maven dependency:
68
71
<dependency>
69
72
<groupId>org.springframework.data</groupId>
70
73
<artifactId>spring-data-mongodb</artifactId>
71
-
<version>${version}.RELEASE</version>
74
+
<version>${version}</version>
72
75
</dependency>
73
76
----
74
77
75
-
If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository and declare the appropriate dependency version.
78
+
If you'd rather like the latest snapshots of the upcoming major version, use our Maven snapshot repository
79
+
and declare the appropriate dependency version.
76
80
77
81
[source,xml]
78
82
----
79
83
<dependency>
80
84
<groupId>org.springframework.data</groupId>
81
85
<artifactId>spring-data-mongodb</artifactId>
82
-
<version>${version}.BUILD-SNAPSHOT</version>
86
+
<version>${version}-SNAPSHOT</version>
83
87
</dependency>
84
88
85
89
<repository>
86
-
<id>spring-libs-snapshot</id>
90
+
<id>spring-snapshot</id>
87
91
<name>Spring Snapshot Repository</name>
88
-
<url>https://repo.spring.io/libs-snapshot</url>
92
+
<url>https://repo.spring.io/snapshot</url>
89
93
</repository>
90
94
----
91
95
@@ -98,7 +102,7 @@ Some of the changes affect the initial setup configuration as well as compile/ru
98
102
99
103
.Changed XML Namespace Elements and Attributes:
100
104
|===
101
-
Element / Attribute | 2.x | 3.x
105
+
| Element / Attribute | 2.x | 3.x
102
106
103
107
| `<mongo:mongo-client />`
104
108
| Used to create a `com.mongodb.MongoClient`
@@ -116,7 +120,7 @@ Use `<mongo:client-settings cluster-hosts="..." />` instead
116
120
117
121
.Removed XML Namespace Elements and Attributes:
118
122
|===
119
-
Element / Attribute | Replacement in 3.x | Comment
123
+
| Element / Attribute | Replacement in 3.x | Comment
120
124
121
125
| `<mongo:db-factory mongo-ref="..." />`
122
126
| `<mongo:db-factory mongo-client-ref="..." />`
@@ -133,7 +137,7 @@ Element / Attribute | Replacement in 3.x | Comment
133
137
134
138
.New XML Namespace Elements and Attributes:
135
139
|===
136
-
Element | Comment
140
+
| Element | Comment
137
141
138
142
| `<mongo:db-factory mongo-client-ref="..." />`
139
143
| Replacement for `<mongo:db-factory mongo-ref="..." />`
@@ -153,7 +157,7 @@ Element | Comment
153
157
154
158
.Java API changes
155
159
|===
156
-
Type | Comment
160
+
| Type | Comment
157
161
158
162
| `MongoClientFactoryBean`
159
163
| Creates `com.mongodb.client.MongoClient` instead of `com.mongodb.MongoClient` +
@@ -174,7 +178,7 @@ Uses `MongoClientSettings` instead of `MongoClientOptions`.
174
178
175
179
.Removed Java API:
176
180
|===
177
-
2.x | Replacement in 3.x | Comment
181
+
| 2.x | Replacement in 3.x | Comment
178
182
179
183
| `MongoClientOptionsFactoryBean`
180
184
| `MongoClientSettingsFactoryBean`
@@ -226,6 +230,7 @@ static class Config extends AbstractMongoClientConfiguration {
226
230
----
227
231
====
228
232
233
+
[[getting-help]]
229
234
== Getting Help
230
235
231
236
Having trouble with Spring Data? We’d love to help!
@@ -239,6 +244,7 @@ If you are just starting out with Spring, try one of the https://spring.io/guide
239
244
You can also chat with the community on https://gitter.im/spring-projects/spring-data[Gitter].
240
245
* Report bugs with Spring Data MongoDB at https://github.com/spring-projects/spring-data-mongodb/issues[github.com/spring-projects/spring-data-mongodb/issues].
241
246
247
+
[[reporting-issues]]
242
248
== Reporting Issues
243
249
244
250
Spring Data uses Github as issue tracking system to record bugs and feature requests.
@@ -249,10 +255,135 @@ If you want to raise an issue, please follow the recommendations below:
249
255
* Please provide as much information as possible with the issue report, we like to know the version of Spring Data that you are using, the JVM version, Stacktrace, etc.
250
256
* If you need to paste code, or include a stack trace use https://guides.github.com/features/mastering-markdown/[Markdown] code fences +++```+++.
251
257
258
+
[[building-from-source]]
252
259
== Building from Source
253
260
254
-
You don’t need to build from source to use Spring Data (binaries in https://repo.spring.io[repo.spring.io]), but if you want to try out the latest and greatest, Spring Data can be easily built with the https://github.com/takari/maven-wrapper[maven wrapper].
255
-
You also need JDK 1.8.
261
+
You do not need to build from source to use Spring Data. Binaries are available in https://repo.spring.io[repo.spring.io].
262
+
and accessible from Maven using the Maven configuration noted <<maven-configuration,above>>.
263
+
264
+
NOTE: Configuration for Gradle is similar to Maven.
265
+
266
+
The best way to get started is by creating a Spring Boot project using MongoDB on https://start.spring.io[start.spring.io].
267
+
Follow this https://start.spring.io/#type=maven-project&language=java&platformVersion=2.5.4&packaging=jar&jvmVersion=1.8&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=data-mongodb[link]
268
+
to build an imperative application and this https://start.spring.io/#type=maven-project&language=java&platformVersion=2.5.4&packaging=jar&jvmVersion=1.8&groupId=com.example&artifactId=demo&name=demo&description=Demo%20project%20for%20Spring%20Boot&packageName=com.example.demo&dependencies=data-mongodb-reactive[link]
269
+
to build a reactive one.
270
+
271
+
However, if you want to try out the latest and greatest, Spring Data can be easily built with the https://github.com/takari/maven-wrapper[maven wrapper]
272
+
and minimally JDK 8 (https://www.oracle.com/java/technologies/downloads/[JDK downloads]).
273
+
274
+
In order to build Spring Data MongoDB, first you will need to https://www.mongodb.com/try/download/community[download]
275
+
and install a MongoDB distribution. Select "_On-premises (MongoDB locally)_", then "_MongoDB Community Server_"
276
+
and in the page form, select the platform matching your system along with the version of MongoDB on which Spring Data
277
+
MongoDB is based (https://github.com/spring-projects/spring-data-mongodb/blob/3.2.5/pom.xml#L30[for example]).
278
+
279
+
Once you have installed MongoDB, you need to start a MongoDB server. It is convenient to set an environment variable to
280
+
your MongoDB installation (e.g. `MONGODB_HOME`).
281
+
282
+
To run the MongoDB server enter the following command from a command-line:
"msg":"Successfully connected to host","attr":{"connString":"127.0.0.1:27017","numOpenConns":1,"socketTimeoutSecs":0.0}}
290
+
----
291
+
292
+
Once the MongoDB server starts up, you should see the message (`msg`), "_Successfully connected to host_".
293
+
294
+
Notice the `--dbpath` option to the `mongod` command. You can set this to anything you like, but in this case, we set
295
+
the absolute path to a sub-directory (`runtime/data/`) under the MongoDB installation directory (in `$MONGODB_HOME`).
296
+
You might have other sub-directories as well, such as `runtime/logs/` for instance, if you wish to write your logs to
297
+
a file rather than standard out, using the `--logpath` option to the `mongod` command. In this way, all your "runtime"
298
+
files for the MongoDB server are conveniently located in one place.
299
+
300
+
Next, you need to initialize the MongoDB replica set the first time the MongoDB server is started. Replicas are used by
301
+
the Spring Data MongoDB transactional tests. This only needs to be done once after the initial start. If you restart
302
+
your MongoDB server, you will need to initialize the replica set again. However, you can continue to use the same
303
+
MongoDB server for multiple builds of Spring Data MongoDB.
304
+
305
+
To initialize the replica set, you must start a mongo client:
306
+
307
+
[source,bash]
308
+
----
309
+
$ $MONGODB_HOME/bin/mongo
310
+
MongoDB server version: 4.4.8
311
+
---
312
+
The server generated these startup warnings when booting:
313
+
2021-09-22T11:26:50.752-07:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
314
+
2021-09-22T11:26:50.752-07:00: This server is bound to localhost. Remote systems will be unable to connect to this server. Start the server with --bind_ip <address> to specify which IP addresses it should serve responses from, or with --bind_ip_all to bind to all interfaces. If this behavior is desired, start the server with --bind_ip 127.0.0.1 to disable this warning
315
+
2021-09-22T11:26:50.752-07:00: Soft rlimits too low
Finally, you may need to adjust the `ulimit` on your UNIX-based system (for example, Linux or Mac OS X). Currently,
356
+
the MongoDB client/server combination uses many Socket connections (which equate to file descriptors on a UNIX-based
357
+
system) throughout the Spring Data MongoDB test suite lifecycle. You can inspect your current `ulimit` with
358
+
the following command:
359
+
360
+
[source,bash]
361
+
----
362
+
$ ulimit -a
363
+
core file size (blocks, -c) 0
364
+
data seg size (kbytes, -d) unlimited
365
+
file size (blocks, -f) unlimited
366
+
max locked memory (kbytes, -l) unlimited
367
+
max memory size (kbytes, -m) unlimited
368
+
open files (-n) 256
369
+
pipe size (512 bytes, -p) 1
370
+
stack size (kbytes, -s) 8192
371
+
cpu time (seconds, -t) unlimited
372
+
max user processes (-u) 5568
373
+
virtual memory (kbytes, -v) unlimited
374
+
----
375
+
376
+
In this case, we are interested in the `ulimit` setting for "_open files_". As you can see above, this is set to 256.
377
+
You will need to adjust this with the following command (we recommend 32768):
378
+
379
+
[source,bash]
380
+
----
381
+
$ ulimit -n 32768
382
+
----
383
+
384
+
You can use `ulimit -a` again to verify the `ulimit` on "_open files_" was set appropriately.
385
+
386
+
Now you are ready to build Spring Data MongoDB. Simply enter the following `mvnw` (Maven Wrapper) command:
256
387
257
388
[source,bash]
258
389
----
@@ -261,7 +392,8 @@ You also need JDK 1.8.
261
392
262
393
If you want to build with the regular `mvn` command, you will need https://maven.apache.org/run-maven/index.html[Maven v3.5.0 or above].
263
394
264
-
_Also see link:CONTRIBUTING.adoc[CONTRIBUTING.adoc] if you wish to submit pull requests, and in particular please sign the https://cla.pivotal.io/sign/spring[Contributor’s Agreement] before your first non-trivial change._
395
+
_Also see link:CONTRIBUTING.adoc[CONTRIBUTING.adoc] if you wish to submit pull requests, and in particular, please sign
396
+
the https://cla.pivotal.io/sign/spring[Contributor’s Agreement] before your first non-trivial change._
0 commit comments