[JAVA-11876] Split spring-boot-mongodb module

This commit is contained in:
Haroon Khan 2022-05-12 18:59:40 +01:00
parent 723069e599
commit 870dc43c9d
12 changed files with 72 additions and 3 deletions

View File

@ -60,6 +60,7 @@
<module>spring-boot-persistence</module> <module>spring-boot-persistence</module>
<module>spring-boot-persistence-h2</module> <module>spring-boot-persistence-h2</module>
<module>spring-boot-persistence-mongodb</module> <module>spring-boot-persistence-mongodb</module>
<module>spring-boot-persistence-mongodb-2</module>
<module>spring-data-arangodb</module> <module>spring-data-arangodb</module>
<module>spring-data-cassandra</module> <module>spring-data-cassandra</module>
<module>spring-data-cassandra-test</module> <module>spring-data-cassandra-test</module>

View File

@ -0,0 +1,2 @@
/.idea/
/target/

View File

@ -0,0 +1,4 @@
# Relevant Articles
- [Logging MongoDB Queries with Spring Boot](https://www.baeldung.com/spring-boot-mongodb-logging)
- More articles: [[<--prev]](../spring-boot-persistence-mongodb)

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>spring-boot-persistence-mongodb-2</artifactId>
<name>spring-boot-persistence-mongodb-2</name>
<packaging>war</packaging>
<description>This is simple boot application for Spring boot persistence mongodb test</description>
<parent>
<groupId>com.baeldung</groupId>
<artifactId>parent-boot-2</artifactId>
<version>0.0.1-SNAPSHOT</version>
<relativePath>../../parent-boot-2</relativePath>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-mongodb</artifactId>
</dependency>
<dependency>
<groupId>de.flapdoodle.embed</groupId>
<artifactId>de.flapdoodle.embed.mongo</artifactId>
<version>${embed.mongo.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
<properties>
<embed.mongo.version>3.2.6</embed.mongo.version>
</properties>
</project>

View File

@ -0,0 +1,13 @@
package com.baeldung;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class SpringBootPersistenceApplication {
public static void main(String ... args) {
SpringApplication.run(SpringBootPersistenceApplication.class, args);
}
}

View File

@ -0,0 +1 @@
spring.application.name=spring-boot-persistence-mongodb-2

View File

@ -35,7 +35,7 @@ import de.flapdoodle.embed.mongo.distribution.Version;
import de.flapdoodle.embed.process.runtime.Network; import de.flapdoodle.embed.process.runtime.Network;
@SpringBootTest @SpringBootTest
@TestPropertySource(properties = { "logging.level.org.springframework.data.mongodb.core.MongoTemplate=DEBUG" }) @TestPropertySource(properties = { "logging.level.org.springframework.data.mongodb.core.MongoTemplate=INFO" })
public class LoggingUnitTest { public class LoggingUnitTest {
private static final String CONNECTION_STRING = "mongodb://%s:%d"; private static final String CONNECTION_STRING = "mongodb://%s:%d";
@ -51,7 +51,7 @@ public class LoggingUnitTest {
@BeforeEach @BeforeEach
void setup() throws Exception { void setup() throws Exception {
String ip = "localhost"; String ip = "localhost";
int port = SocketUtils.findAvailableTcpPort(); int port = Network.freeServerPort(Network.getLocalHost());
ImmutableMongodConfig mongodConfig = MongodConfig.builder() ImmutableMongodConfig mongodConfig = MongodConfig.builder()
.version(Version.Main.PRODUCTION) .version(Version.Main.PRODUCTION)

View File

@ -0,0 +1 @@
spring.mongodb.embedded.version=4.4.9

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration scan="true" scanPeriod="15 seconds" debug="false">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>[%d{ISO8601}]-[%thread] %-5level %logger - %msg%n</pattern>
</encoder>
</appender>
<root level="INFO">
<appender-ref ref="STDOUT" />
</root>
</configuration>

View File

@ -7,4 +7,4 @@
- [ZonedDateTime with Spring Data MongoDB](https://www.baeldung.com/spring-data-mongodb-zoneddatetime) - [ZonedDateTime with Spring Data MongoDB](https://www.baeldung.com/spring-data-mongodb-zoneddatetime)
- [A Guide to @DBRef in MongoDB](https://www.baeldung.com/spring-mongodb-dbref-annotation) - [A Guide to @DBRef in MongoDB](https://www.baeldung.com/spring-mongodb-dbref-annotation)
- [Import Data to MongoDB From JSON File Using Java](https://www.baeldung.com/java-import-json-mongodb) - [Import Data to MongoDB From JSON File Using Java](https://www.baeldung.com/java-import-json-mongodb)
- [Logging MongoDB Queries with Spring Boot](https://www.baeldung.com/spring-boot-mongodb-logging) - More articles: [[next-->]](../spring-boot-persistence-mongodb-2)