Flesh out and polish Embedded MongoDB auto-configuration contribution

Embedded MongoDB is now auto-configured when it is on the classpath.
The Mongo instance will listen on the port specified by the
spring.data.mongodb.port property. If this property has a value of
zero and randomly allocated port will be used. In such an event, the
MongoClient created by MongoAutoConfiguration will be automatically
configured to use the port that was allocated.

By default, MongoDB 2.6.10 will be used. This can be configured using
the spring.embedded-mongodb.version property. Mongo's sync delay
feature is enabled by default. This can be configured using the
spring.embedded-mongobd.features property.

Closes gh-2002
This commit is contained in:
Andy Wilkinson
2014-11-26 11:40:31 +00:00
parent f2b2c085e9
commit 2c81907d58
19 changed files with 710 additions and 200 deletions

View File

@@ -334,6 +334,10 @@ content into your application; rather pick only the properties that you need.
spring.data.mongodb.repositories.enabled=true # if spring data repository support is enabled
spring.data.mongodb.field-naming-strategy= # fully qualified name of the FieldNamingStrategy to use
# EMBEDDED MONGODB ({sc-spring-boot-autoconfigure}/mongo/embedded/EmbeddedMongoProerties.{sc-ext}[EmbeddedMongoProperties])
spring.embedded-mongodb.version=2.6.10 # version of Mongo to use
spring.embedded-mongodb.features=SYNC_DELAY # comma-separated list of features to enable
# JPA ({sc-spring-boot-autoconfigure}/orm/jpa/JpaBaseConfiguration.{sc-ext}[JpaBaseConfiguration], {sc-spring-boot-autoconfigure}/orm/jpa/HibernateJpaAutoConfiguration.{sc-ext}[HibernateJpaAutoConfiguration])
spring.jpa.properties.*= # properties to set on the JPA connection
spring.jpa.open-in-view=true

View File

@@ -2478,6 +2478,26 @@ documentation].
[[boot-features-mongo-embedded]]
==== Embedded Mongo
Spring Boot offers auto-configuration for
[https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo] Embedded Mongo. To use
it in your Spring Boot application add a dependency on
`de.flapdoodle.embed:de.flapdoodle.embed.mongo`.
The port that Mongo will listen on can be configured using the `spring.data.mongodb.port`
property. To use a randomly allocated free port use a value of zero. The `MongoClient`
created by `MongoAutoConfiguration` will be automatically configured to use the randomly
allocated port.
If you have SLF4J on the classpath, output produced by Mongo will be automatically routed
to a logger named `org.springframework.boot.autoconfigure.mongo.embedded.EmbeddedMongo`.
You can declare your own `IMongodConfig` and `IRuntimeConfig` beans to take control of the
Mongo instance's configuration and logging routing.
[[boot-features-gemfire]]
=== Gemfire
https://github.com/spring-projects/spring-data-gemfire[Spring Data Gemfire] provides