Create spring-boot-data-mongodb module

See gh-46115
This commit is contained in:
Andy Wilkinson 2025-03-26 14:40:05 +00:00
parent 54e9da7ecd
commit 3fe58a2c39
47 changed files with 171 additions and 283 deletions

View File

@ -70,6 +70,7 @@ include "spring-boot-project:spring-boot-cassandra"
include "spring-boot-project:spring-boot-couchbase"
include "spring-boot-project:spring-boot-data-jpa"
include "spring-boot-project:spring-boot-data-ldap"
include "spring-boot-project:spring-boot-data-mongodb"
include "spring-boot-project:spring-boot-dependencies"
include "spring-boot-project:spring-boot-devtools"
include "spring-boot-project:spring-boot-docker-compose"

View File

@ -39,6 +39,7 @@ dependencies {
optional(project(":spring-boot-project:spring-boot-cassandra"))
optional(project(":spring-boot-project:spring-boot-couchbase"))
optional(project(":spring-boot-project:spring-boot-data-jpa"))
optional(project(":spring-boot-project:spring-boot-data-mongodb"))
optional(project(":spring-boot-project:spring-boot-elasticsearch"))
optional(project(":spring-boot-project:spring-boot-flyway"))
optional(project(":spring-boot-project:spring-boot-hazelcast"))

View File

@ -26,7 +26,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.data.mongodb.core.MongoTemplate;
@ -36,8 +35,9 @@ import org.springframework.data.mongodb.core.MongoTemplate;
* @author Stephane Nicoll
* @since 2.1.0
*/
@AutoConfiguration(after = { MongoDataAutoConfiguration.class, MongoReactiveHealthContributorAutoConfiguration.class },
afterName = "org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration")
@AutoConfiguration(after = MongoReactiveHealthContributorAutoConfiguration.class,
afterName = { "org.springframework.boot.data.mongodb.autoconfigure.MongoDataAutoConfiguration",
"org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration" })
@ConditionalOnClass(MongoTemplate.class)
@ConditionalOnBean(MongoTemplate.class)
@ConditionalOnEnabledHealthIndicator("mongo")

View File

@ -28,7 +28,6 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
@ -39,7 +38,7 @@ import org.springframework.data.mongodb.core.ReactiveMongoTemplate;
* @author Stephane Nicoll
* @since 2.1.0
*/
@AutoConfiguration(after = MongoReactiveDataAutoConfiguration.class)
@AutoConfiguration(afterName = "org.springframework.boot.data.mongodb.autoconfigure.MongoReactiveDataAutoConfiguration")
@ConditionalOnClass({ ReactiveMongoTemplate.class, Flux.class })
@ConditionalOnBean(ReactiveMongoTemplate.class)
@ConditionalOnEnabledHealthIndicator("mongo")

View File

@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAutoConfiguration;
import org.springframework.boot.actuate.data.mongo.MongoHealthIndicator;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.data.mongodb.autoconfigure.MongoDataAutoConfiguration;
import org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;

View File

@ -22,8 +22,8 @@ import org.springframework.boot.actuate.autoconfigure.health.HealthContributorAu
import org.springframework.boot.actuate.data.mongo.MongoHealthIndicator;
import org.springframework.boot.actuate.data.mongo.MongoReactiveHealthIndicator;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration;
import org.springframework.boot.data.mongodb.autoconfigure.MongoDataAutoConfiguration;
import org.springframework.boot.data.mongodb.autoconfigure.MongoReactiveDataAutoConfiguration;
import org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration;
import org.springframework.boot.mongodb.autoconfigure.MongoReactiveAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;

View File

@ -26,8 +26,6 @@ import org.springframework.boot.actuate.health.ReactiveHealthEndpointWebExtensio
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.data.cassandra.CassandraDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.neo4j.Neo4jRepositoriesAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
@ -35,6 +33,8 @@ import org.springframework.boot.autoconfigure.data.redis.RedisRepositoriesAutoCo
import org.springframework.boot.autoconfigure.data.rest.RepositoryRestMvcAutoConfiguration;
import org.springframework.boot.cassandra.autoconfigure.CassandraAutoConfiguration;
import org.springframework.boot.context.annotation.UserConfigurations;
import org.springframework.boot.data.mongodb.autoconfigure.MongoDataAutoConfiguration;
import org.springframework.boot.data.mongodb.autoconfigure.MongoReactiveDataAutoConfiguration;
import org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration;
import org.springframework.boot.hazelcast.autoconfigure.HazelcastAutoConfiguration;
import org.springframework.boot.liquibase.autoconfigure.LiquibaseAutoConfiguration;

View File

@ -63,6 +63,7 @@ dependencies {
optional(project(":spring-boot-project:spring-boot-cassandra"))
optional(project(":spring-boot-project:spring-boot-couchbase"))
optional(project(":spring-boot-project:spring-boot-data-jpa"))
optional(project(":spring-boot-project:spring-boot-data-mongodb"))
optional(project(":spring-boot-project:spring-boot-elasticsearch"))
optional(project(":spring-boot-project:spring-boot-flyway"))
optional(project(":spring-boot-project:spring-boot-h2console"))

View File

@ -25,9 +25,9 @@ import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration;
import org.springframework.boot.autoconfigure.web.reactive.WebSessionIdResolverAutoConfiguration;
import org.springframework.boot.data.mongodb.autoconfigure.MongoDataAutoConfiguration;
import org.springframework.boot.data.mongodb.autoconfigure.MongoReactiveDataAutoConfiguration;
import org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration;
import org.springframework.boot.mongodb.autoconfigure.MongoReactiveAutoConfiguration;
import org.springframework.boot.test.context.FilteredClassLoader;

View File

@ -24,8 +24,8 @@ import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerProperties;
import org.springframework.boot.data.mongodb.autoconfigure.MongoDataAutoConfiguration;
import org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration;
import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;

View File

@ -27,8 +27,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
import org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
import org.springframework.boot.autoconfigure.data.redis.RedisReactiveAutoConfiguration;
import org.springframework.boot.autoconfigure.web.ServerProperties;
@ -66,12 +64,13 @@ import org.springframework.session.web.http.HttpSessionIdResolver;
* @since 1.4.0
*/
@AutoConfiguration(
after = { MongoDataAutoConfiguration.class, MongoReactiveDataAutoConfiguration.class,
RedisAutoConfiguration.class, RedisReactiveAutoConfiguration.class,
after = { RedisAutoConfiguration.class, RedisReactiveAutoConfiguration.class,
WebSessionIdResolverAutoConfiguration.class },
afterName = { "org.springframework.boot.hazelcast.autoconfigure.HazelcastAutoConfiguration",
"org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration",
"org.springframework.boot.jdbc.autoconfigure.JdbcTemplateAutoConfiguration" },
"org.springframework.boot.jdbc.autoconfigure.JdbcTemplateAutoConfiguration",
"org.springframework.boot.data.mongodb.autoconfigure.MongoDataAutoConfiguration",
"org.springframework.boot.data.mongodb.autoconfigure.MongoReactiveDataAutoConfiguration" },
before = { HttpHandlerAutoConfiguration.class, WebFluxAutoConfiguration.class })
@ConditionalOnClass(Session.class)
@ConditionalOnWebApplication

View File

@ -1277,33 +1277,6 @@
}
]
},
{
"name": "spring.data.mongodb.field-naming-strategy",
"providers": [
{
"name": "class-reference",
"parameters": {
"target": "org.springframework.data.mapping.model.FieldNamingStrategy"
}
}
]
},
{
"name": "spring.data.mongodb.protocol",
"values": [
{
"value": "mongodb"
},
{
"value": "mongodb+srv"
}
],
"providers": [
{
"name": "any"
}
]
},
{
"name": "spring.data.redis.lettuce.read-from",
"values": [

View File

@ -13,10 +13,6 @@ org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchDataAutoC
org.springframework.boot.autoconfigure.data.elasticsearch.ElasticsearchRepositoriesAutoConfiguration
org.springframework.boot.autoconfigure.data.elasticsearch.ReactiveElasticsearchRepositoriesAutoConfiguration
org.springframework.boot.autoconfigure.data.jdbc.JdbcRepositoriesAutoConfiguration
org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration
org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration
org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration
org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration
org.springframework.boot.autoconfigure.data.neo4j.Neo4jDataAutoConfiguration
org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveDataAutoConfiguration
org.springframework.boot.autoconfigure.data.neo4j.Neo4jReactiveRepositoriesAutoConfiguration

View File

@ -1,160 +0,0 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
import java.util.ArrayList;
import java.util.List;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
import org.springframework.boot.autoconfigure.data.alt.jpa.City;
import org.springframework.boot.autoconfigure.data.alt.jpa.CityJpaRepository;
import org.springframework.boot.autoconfigure.data.mongo.country.Country;
import org.springframework.boot.autoconfigure.data.mongo.country.CountryRepository;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.data.jpa.autoconfigure.JpaRepositoriesAutoConfiguration;
import org.springframework.boot.jdbc.autoconfigure.DataSourceAutoConfiguration;
import org.springframework.boot.jpa.autoconfigure.hibernate.HibernateJpaAutoConfiguration;
import org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.data.mongodb.repository.config.EnableMongoRepositories;
import org.springframework.util.StringUtils;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Tests for {@link MongoRepositoriesAutoConfiguration}.
*
* @author Dave Syer
* @author Oliver Gierke
*/
class MixedMongoRepositoriesAutoConfigurationTests {
private AnnotationConfigApplicationContext context;
@AfterEach
void close() {
this.context.close();
}
@Test
void testDefaultRepositoryConfiguration() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(TestConfiguration.class, BaseConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(CountryRepository.class)).isNotNull();
}
@Test
void testMixedRepositoryConfiguration() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(MixedConfiguration.class, BaseConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(CountryRepository.class)).isNotNull();
assertThat(this.context.getBean(CityJpaRepository.class)).isNotNull();
}
@Test
void testJpaRepositoryConfigurationWithMongoTemplate() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(JpaConfiguration.class, BaseConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(CityJpaRepository.class)).isNotNull();
}
@Test
void testJpaRepositoryConfigurationWithMongoOverlap() {
this.context = new AnnotationConfigApplicationContext();
this.context.register(OverlapConfiguration.class, BaseConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(CityJpaRepository.class)).isNotNull();
}
@Test
void testJpaRepositoryConfigurationWithMongoOverlapDisabled() {
this.context = new AnnotationConfigApplicationContext();
TestPropertyValues.of("spring.data.mongodb.repositories.type:none").applyTo(this.context);
this.context.register(OverlapConfiguration.class, BaseConfiguration.class);
this.context.refresh();
assertThat(this.context.getBean(CityJpaRepository.class)).isNotNull();
}
@Configuration(proxyBeanMethods = false)
@TestAutoConfigurationPackage(MongoAutoConfiguration.class)
// Not this package or its parent
@EnableMongoRepositories(basePackageClasses = Country.class)
static class TestConfiguration {
}
@Configuration(proxyBeanMethods = false)
@TestAutoConfigurationPackage(MongoAutoConfiguration.class)
@EnableMongoRepositories(basePackageClasses = Country.class)
@EntityScan(basePackageClasses = City.class)
@EnableJpaRepositories(basePackageClasses = CityJpaRepository.class)
static class MixedConfiguration {
}
@Configuration(proxyBeanMethods = false)
@TestAutoConfigurationPackage(MongoAutoConfiguration.class)
@EntityScan(basePackageClasses = City.class)
@EnableJpaRepositories(basePackageClasses = CityJpaRepository.class)
static class JpaConfiguration {
}
// In this one the Jpa repositories and the auto-configuration packages overlap, so
// Mongo will try and configure the same repositories
@Configuration(proxyBeanMethods = false)
@TestAutoConfigurationPackage(CityJpaRepository.class)
@EnableJpaRepositories(basePackageClasses = CityJpaRepository.class)
static class OverlapConfiguration {
}
@Configuration(proxyBeanMethods = false)
@Import(Registrar.class)
static class BaseConfiguration {
}
static class Registrar implements ImportSelector {
@Override
public String[] selectImports(AnnotationMetadata importingClassMetadata) {
List<String> names = new ArrayList<>();
for (Class<?> type : new Class<?>[] { DataSourceAutoConfiguration.class,
HibernateJpaAutoConfiguration.class, JpaRepositoriesAutoConfiguration.class,
MongoAutoConfiguration.class, MongoDataAutoConfiguration.class,
MongoRepositoriesAutoConfiguration.class }) {
names.add(type.getName());
}
return StringUtils.toStringArray(names);
}
}
}

View File

@ -0,0 +1,42 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the License);
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
plugins {
id "java-library"
id "org.springframework.boot.auto-configuration"
id "org.springframework.boot.deployed"
id "org.springframework.boot.optional-dependencies"
}
description = "Spring Boot Data MongoDB"
dependencies {
api(project(":spring-boot-project:spring-boot"))
api(project(":spring-boot-project:spring-boot-mongodb"))
api("org.springframework.data:spring-data-mongodb")
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
optional("io.projectreactor:reactor-core")
optional("org.mongodb:mongodb-driver-reactivestreams")
optional("org.mongodb:mongodb-driver-sync")
testImplementation(project(":spring-boot-project:spring-boot-test"))
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
testImplementation(testFixtures(project(":spring-boot-project:spring-boot-autoconfigure")))
testRuntimeOnly("ch.qos.logback:logback-classic")
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import com.mongodb.client.MongoClient;
@ -50,7 +50,7 @@ import org.springframework.data.mongodb.gridfs.GridFsTemplate;
* @author Eddú Meléndez
* @author Stephane Nicoll
* @author Christoph Strobl
* @since 1.1.0
* @since 4.0.0
*/
@AutoConfiguration(after = MongoAutoConfiguration.class)
@ConditionalOnClass({ MongoClient.class, MongoTemplate.class })

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import java.util.Collections;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import com.mongodb.client.MongoClient;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import com.mongodb.ClientSessionOptions;
import com.mongodb.client.ClientSession;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import java.util.Optional;
@ -65,7 +65,7 @@ import org.springframework.util.StringUtils;
* @author Andy Wilkinson
* @author Phillip Webb
* @author Scott Frederick
* @since 2.0.0
* @since 4.0.0
*/
@AutoConfiguration(after = MongoReactiveAutoConfiguration.class)
@ConditionalOnClass({ MongoClient.class, ReactiveMongoTemplate.class })

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import com.mongodb.reactivestreams.client.MongoClient;
@ -45,7 +45,7 @@ import org.springframework.data.mongodb.repository.support.ReactiveMongoReposito
* annotation.
*
* @author Mark Paluch
* @since 2.0.0
* @since 4.0.0
* @see EnableReactiveMongoRepositories
*/
@AutoConfiguration(after = MongoReactiveDataAutoConfiguration.class)

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import java.lang.annotation.Annotation;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import com.mongodb.client.MongoClient;
@ -47,7 +47,7 @@ import org.springframework.data.mongodb.repository.support.MongoRepositoryFactor
* @author Dave Syer
* @author Oliver Gierke
* @author Josh Long
* @since 1.0.0
* @since 4.0.0
* @see EnableMongoRepositories
*/
@AutoConfiguration(after = MongoDataAutoConfiguration.class)

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import java.lang.annotation.Annotation;

View File

@ -15,6 +15,6 @@
*/
/**
* Auto-configuration for Spring Data Mongo.
* Auto-configuration for Spring Data MongoDB.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;

View File

@ -0,0 +1,31 @@
{
"hints": [
{
"name": "spring.data.mongodb.field-naming-strategy",
"providers": [
{
"name": "class-reference",
"parameters": {
"target": "org.springframework.data.mapping.model.FieldNamingStrategy"
}
}
]
},
{
"name": "spring.data.mongodb.protocol",
"values": [
{
"value": "mongodb"
},
{
"value": "mongodb+srv"
}
],
"providers": [
{
"name": "any"
}
]
}
]
}

View File

@ -0,0 +1,4 @@
org.springframework.boot.data.mongodb.autoconfigure.MongoDataAutoConfiguration
org.springframework.boot.data.mongodb.autoconfigure.MongoReactiveDataAutoConfiguration
org.springframework.boot.data.mongodb.autoconfigure.MongoReactiveRepositoriesAutoConfiguration
org.springframework.boot.data.mongodb.autoconfigure.MongoRepositoriesAutoConfiguration

View File

@ -14,9 +14,9 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.alt.mongo;
package org.springframework.boot.data.mongodb.alt;
import org.springframework.boot.autoconfigure.data.mongo.city.City;
import org.springframework.boot.data.mongodb.autoconfigure.domain.city.City;
import org.springframework.data.repository.Repository;
public interface CityMongoDbRepository extends Repository<City, Long> {

View File

@ -14,9 +14,9 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.alt.mongo;
package org.springframework.boot.data.mongodb.alt;
import org.springframework.boot.autoconfigure.data.mongo.city.City;
import org.springframework.boot.data.mongodb.autoconfigure.domain.city.City;
import org.springframework.data.repository.reactive.ReactiveCrudRepository;
public interface ReactiveCityMongoDbRepository extends ReactiveCrudRepository<City, Long> {

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import java.time.LocalDateTime;
import java.util.Arrays;
@ -32,9 +32,9 @@ import org.springframework.beans.factory.BeanCreationException;
import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.data.mongo.city.City;
import org.springframework.boot.autoconfigure.data.mongo.country.Country;
import org.springframework.boot.autoconfigure.domain.EntityScan;
import org.springframework.boot.data.mongodb.autoconfigure.domain.city.City;
import org.springframework.boot.data.mongodb.autoconfigure.domain.country.Country;
import org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration;
import org.springframework.boot.mongodb.autoconfigure.MongoConnectionDetails;
import org.springframework.boot.mongodb.autoconfigure.PropertiesMongoConnectionDetails;
@ -345,7 +345,7 @@ class MongoDataAutoConfigurationTests {
}
@Configuration(proxyBeanMethods = false)
@EntityScan("org.springframework.boot.autoconfigure.data.mongo")
@EntityScan("org.springframework.boot.data.mongodb.autoconfigure")
static class EntityScanConfig {
}

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import java.util.ArrayList;
import java.util.List;
@ -23,8 +23,8 @@ import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
import org.springframework.boot.autoconfigure.data.mongo.city.CityRepository;
import org.springframework.boot.autoconfigure.data.mongo.city.ReactiveCityRepository;
import org.springframework.boot.data.mongodb.autoconfigure.domain.city.CityRepository;
import org.springframework.boot.data.mongodb.autoconfigure.domain.city.ReactiveCityRepository;
import org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration;
import org.springframework.boot.mongodb.autoconfigure.MongoReactiveAutoConfiguration;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import java.time.Duration;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import com.mongodb.reactivestreams.client.MongoClient;
import org.junit.jupiter.api.Test;
@ -22,11 +22,11 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.data.alt.mongo.CityMongoDbRepository;
import org.springframework.boot.autoconfigure.data.alt.mongo.ReactiveCityMongoDbRepository;
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
import org.springframework.boot.autoconfigure.data.mongo.city.City;
import org.springframework.boot.autoconfigure.data.mongo.city.ReactiveCityRepository;
import org.springframework.boot.data.mongodb.alt.CityMongoDbRepository;
import org.springframework.boot.data.mongodb.alt.ReactiveCityMongoDbRepository;
import org.springframework.boot.data.mongodb.autoconfigure.domain.city.City;
import org.springframework.boot.data.mongodb.autoconfigure.domain.city.ReactiveCityRepository;
import org.springframework.boot.data.mongodb.autoconfigure.empty.EmptyDataPackage;
import org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration;
import org.springframework.boot.mongodb.autoconfigure.MongoReactiveAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo;
package org.springframework.boot.data.mongodb.autoconfigure;
import com.mongodb.client.MongoClient;
import org.junit.jupiter.api.Test;
@ -22,10 +22,10 @@ import org.junit.jupiter.api.Test;
import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.autoconfigure.TestAutoConfigurationPackage;
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
import org.springframework.boot.autoconfigure.data.alt.mongo.CityMongoDbRepository;
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
import org.springframework.boot.autoconfigure.data.mongo.city.City;
import org.springframework.boot.autoconfigure.data.mongo.city.CityRepository;
import org.springframework.boot.data.mongodb.alt.CityMongoDbRepository;
import org.springframework.boot.data.mongodb.autoconfigure.domain.city.City;
import org.springframework.boot.data.mongodb.autoconfigure.domain.city.CityRepository;
import org.springframework.boot.data.mongodb.autoconfigure.empty.EmptyDataPackage;
import org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.context.annotation.Configuration;

View File

@ -14,14 +14,10 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo.city;
package org.springframework.boot.data.mongodb.autoconfigure.domain.city;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document
@ -29,20 +25,12 @@ public class City implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
@Column(nullable = false)
private String name;
@Column(nullable = false)
private String state;
@Column(nullable = false)
private String country;
@Column(nullable = false)
private String map;
protected City() {

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo.city;
package org.springframework.boot.data.mongodb.autoconfigure.domain.city;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo.city;
package org.springframework.boot.data.mongodb.autoconfigure.domain.city;
import java.io.Serializable;

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo.city;
package org.springframework.boot.data.mongodb.autoconfigure.domain.city;
import reactor.core.publisher.Flux;

View File

@ -14,14 +14,10 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo.country;
package org.springframework.boot.data.mongodb.autoconfigure.domain.country;
import java.io.Serializable;
import jakarta.persistence.Column;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document
@ -29,11 +25,6 @@ public class Country implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@GeneratedValue
private Long id;
@Column(nullable = false)
private String name;
protected Country() {

View File

@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.boot.autoconfigure.data.mongo.country;
package org.springframework.boot.data.mongodb.autoconfigure.domain.country;
import org.springframework.data.repository.Repository;

View File

@ -0,0 +1,21 @@
/*
* Copyright 2012-present the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.springframework.boot.data.mongodb.autoconfigure.empty;
public class EmptyDataPackage {
}

View File

@ -1998,6 +1998,7 @@ bom {
"spring-boot-couchbase",
"spring-boot-data-jpa",
"spring-boot-data-ldap",
"spring-boot-data-mongodb",
"spring-boot-devtools",
"spring-boot-docker-compose",
"spring-boot-elasticsearch",

View File

@ -86,6 +86,7 @@ dependencies {
autoConfiguration(project(path: ":spring-boot-project:spring-boot-couchbase", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-data-jpa", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-data-ldap", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-data-mongodb", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-devtools", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-elasticsearch", configuration: "autoConfigurationMetadata"))
autoConfiguration(project(path: ":spring-boot-project:spring-boot-flyway", configuration: "autoConfigurationMetadata"))

View File

@ -21,10 +21,9 @@ plugins {
description = "Starter for using MongoDB document-oriented database and Spring Data MongoDB Reactive"
dependencies {
api(project(":spring-boot-project:spring-boot-mongodb"))
api(project(":spring-boot-project:spring-boot-data-mongodb"))
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter"))
api(project(":spring-boot-project:spring-boot-tx"))
api("io.projectreactor:reactor-core")
api("org.mongodb:mongodb-driver-reactivestreams")
api("org.springframework.data:spring-data-mongodb")
}

View File

@ -21,9 +21,8 @@ plugins {
description = "Starter for using MongoDB document-oriented database and Spring Data MongoDB"
dependencies {
api(project(":spring-boot-project:spring-boot-mongodb"))
api(project(":spring-boot-project:spring-boot-data-mongodb"))
api(project(":spring-boot-project:spring-boot-starters:spring-boot-starter"))
api(project(":spring-boot-project:spring-boot-tx"))
api("org.mongodb:mongodb-driver-sync")
api("org.springframework.data:spring-data-mongodb")
}

View File

@ -28,11 +28,11 @@ dependencies {
api(project(":spring-boot-project:spring-boot-test"))
api(project(":spring-boot-project:spring-boot-autoconfigure-all"))
dockerTestImplementation(project(":spring-boot-project:spring-boot-data-mongodb"))
dockerTestImplementation(project(":spring-boot-project:spring-boot-docker-compose"))
dockerTestImplementation(project(":spring-boot-project:spring-boot-testcontainers"))
dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
dockerTestImplementation(project(":spring-boot-project:spring-boot-tx"))
dockerTestImplementation("com.zaxxer:HikariCP")
dockerTestImplementation("io.projectreactor:reactor-test")
dockerTestImplementation("com.redis:testcontainers-redis")
@ -57,6 +57,7 @@ dependencies {
optional(project(":spring-boot-project:spring-boot-couchbase"))
optional(project(":spring-boot-project:spring-boot-data-jpa"))
optional(project(":spring-boot-project:spring-boot-data-ldap"))
optional(project(":spring-boot-project:spring-boot-data-mongodb"))
optional(project(":spring-boot-project:spring-boot-elasticsearch"))
optional(project(":spring-boot-project:spring-boot-flyway"))
optional(project(":spring-boot-project:spring-boot-groovy-templates"))

View File

@ -1,9 +1,9 @@
# AutoConfigureDataMongo auto-configuration imports
org.springframework.boot.autoconfigure.data.mongo.MongoDataAutoConfiguration
org.springframework.boot.autoconfigure.data.mongo.MongoReactiveDataAutoConfiguration
org.springframework.boot.autoconfigure.data.mongo.MongoReactiveRepositoriesAutoConfiguration
org.springframework.boot.autoconfigure.data.mongo.MongoRepositoriesAutoConfiguration
org.springframework.boot.autoconfigure.ssl.SslAutoConfiguration
org.springframework.boot.data.mongodb.autoconfigure.MongoDataAutoConfiguration
org.springframework.boot.data.mongodb.autoconfigure.MongoReactiveDataAutoConfiguration
org.springframework.boot.data.mongodb.autoconfigure.MongoReactiveRepositoriesAutoConfiguration
org.springframework.boot.data.mongodb.autoconfigure.MongoRepositoriesAutoConfiguration
org.springframework.boot.mongodb.autoconfigure.MongoAutoConfiguration
org.springframework.boot.mongodb.autoconfigure.MongoReactiveAutoConfiguration
org.springframework.boot.transaction.autoconfigure.TransactionAutoConfiguration