diff --git a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java index d62746e90a..4eb20a8d5d 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfiguration.java @@ -145,7 +145,8 @@ public class EmbeddedMongoAutoConfiguration { } private IFeatureAwareVersion determineVersion(EmbeddedMongoProperties embeddedProperties) { - Assert.state(embeddedProperties.getVersion() != null, "Version must be set to use Embedded MongoDB."); + Assert.state(embeddedProperties.getVersion() != null, "Set the spring.mongodb.embedded.version property or " + + "define your own MongodConfig bean to use embedded MongoDB"); if (embeddedProperties.getFeatures() == null) { for (Version version : Version.values()) { if (version.asInDownloadPath().equals(embeddedProperties.getVersion())) { diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java index c87b94004d..f0d577d4af 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/mongo/embedded/EmbeddedMongoAutoConfigurationTests.java @@ -81,7 +81,8 @@ class EmbeddedMongoAutoConfigurationTests { this.context.register(MongoAutoConfiguration.class, MongoDataAutoConfiguration.class, EmbeddedMongoAutoConfiguration.class); assertThatThrownBy(() -> this.context.refresh()).hasRootCauseExactlyInstanceOf(IllegalStateException.class) - .hasRootCauseMessage("Version must be set to use Embedded MongoDB."); + .hasRootCauseMessage("Set the spring.mongodb.embedded.version property or define your own MongodConfig " + + "bean to use embedded MongoDB"); } @Test diff --git a/spring-boot-project/spring-boot-docs/build.gradle b/spring-boot-project/spring-boot-docs/build.gradle index ebe9085e75..2f6a5f5125 100644 --- a/spring-boot-project/spring-boot-docs/build.gradle +++ b/spring-boot-project/spring-boot-docs/build.gradle @@ -220,7 +220,8 @@ tasks.withType(org.asciidoctor.gradle.jvm.AbstractAsciidoctorTask) { } doFirst { def versionConstraints = dependencyVersions.versionConstraints - attributes "jetty-version": versionConstraints["org.eclipse.jetty:jetty-server"], + attributes "embedded-mongo-version": versionConstraints["de.flapdoodle.embed:de.flapdoodle.embed.mongo"], + "jetty-version": versionConstraints["org.eclipse.jetty:jetty-server"], "jooq-version": versionConstraints["org.jooq:jooq"], "spring-amqp-version": versionConstraints["org.springframework.amqp:spring-amqp"], "spring-batch-version": versionConstraints["org.springframework.batch:spring-batch-core"], diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc index e72b5bab73..941982411e 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/attributes.adoc @@ -93,6 +93,7 @@ :spring-webservices-docs: https://docs.spring.io/spring-ws/docs/{spring-webservices-version}/reference/html/ :ant-docs: https://ant.apache.org/manual :dependency-management-plugin-code: https://github.com/spring-gradle-plugins/dependency-management-plugin +:embedded-mongo-code: https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo/blob/de.flapdoodle.embed.mongo-{embedded-mongo-version} :gradle-docs: https://docs.gradle.org/current/userguide :hibernate-docs: https://docs.jboss.org/hibernate/orm/5.4/userguide/html_single/Hibernate_User_Guide.html :java-api: https://docs.oracle.com/javase/8/docs/api diff --git a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc index 2809edc8e7..4adf9c0b62 100644 --- a/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc +++ b/spring-boot-project/spring-boot-docs/src/docs/asciidoc/data/nosql.adoc @@ -149,14 +149,11 @@ TIP: For complete details of Spring Data MongoDB, including its rich object mapp [[data.nosql.mongodb.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`. +To use it in your Spring Boot application, add a dependency on `de.flapdoodle.embed:de.flapdoodle.embed.mongo` and set the configprop:spring.mongodb.embedded.version[] property to match the version of MongoDB that your application will use in production. -The version of the MongoDB server **must** be configured by setting the configprop:spring.data.mongodb.embedded.version property. - -NOTE: The default download configuration allows access to most of the versions listed in https://github.com/flapdoodle-oss/de.flapdoodle.embed.mongo/blob/de.flapdoodle.embed.mongo-3.0.0/src/main/java/de/flapdoodle/embed/mongo/distribution/Version.java[Version.java] -as well as some others. Inaccessible versions result in error when attempting to download the server. The download configuration may be adjusted to handle the desired version. - -The download configuration can be customized by declaring a `DownloadConfigBuilderCustomizer` bean. +NOTE: The default download configuration allows access to most of the versions listed in {embedded-mongo-code}/src/main/java/de/flapdoodle/embed/mongo/distribution/Version.java[Embedded Mongo's `Version` class] as well as some others. +Configuring an inaccessible version will result in an error when attempting to download the server. +Such an error can be corrected by defining an appropriately configured `DownloadConfigBuilderCustomizer` bean. The port that Mongo listens on can be configured by setting the configprop:spring.data.mongodb.port[] property. To use a randomly allocated free port, use a value of 0. @@ -167,6 +164,7 @@ NOTE: If you do not configure a custom port, the embedded support uses a random If you have SLF4J on the classpath, the output produced by Mongo is 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. +The download configuration can be customized by declaring a `DownloadConfigBuilderCustomizer` bean. [[data.nosql.neo4j]]