Я пытаюсь заставить Spring Data MongoDB (реактивный) работать с Spring Boot 2.1.5 (и WebFlux).
Из журналов запуска я подозреваю, что что-то не так, похоже, что он инициализирован дважды(обратите внимание на два сканирования репозитория, и они даже дают разные результаты):
2019.05.19 11:59:53 | INFO | org.springframework.data.repository.config.RepositoryConfigurationDelegate - Bootstrapping Spring Data repositories in DEFAULT mode.
2019.05.19 11:59:55 | INFO | org.springframework.data.repository.config.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 1235ms. Found 8 repository interfaces.
2019.05.19 11:59:55 | INFO | org.springframework.data.repository.config.RepositoryConfigurationDelegate - Bootstrapping Spring Data repositories in DEFAULT mode.
2019.05.19 11:59:55 | INFO | org.springframework.data.repository.config.RepositoryConfigurationDelegate - Finished Spring Data repository scanning in 64ms. Found 0 repository interfaces.
2019.05.19 11:59:59 | INFO | org.mongodb.driver.cluster - Cluster created with settings {hosts=[localhost:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2019.05.19 11:59:59 | INFO | org.mongodb.driver.cluster - Cluster created with settings {hosts=[localhost:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
2019.05.19 11:59:59 | INFO | org.mongodb.driver.cluster - Adding discovered server localhost:27017 to client view of cluster
2019.05.19 12:00:00 | INFO | org.mongodb.driver.connection - Opened connection [connectionId{localValue:2, serverValue:13}] to localhost:27017
2019.05.19 12:00:00 | INFO | org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 0, 9]}, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=16058831}
2019.05.19 12:00:00 | INFO | org.mongodb.driver.cluster - Discovered cluster type of STANDALONE
2019.05.19 12:00:00 | INFO | org.mongodb.driver.connection - Opened connection [connectionId{localValue:1, serverValue:14}] to localhost:27017
2019.05.19 12:00:00 | INFO | org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=localhost:27017, type=STANDALONE, state=CONNECTED, ok=true, version=ServerVersion{versionList=[4, 0, 9]}, minWireVersion=0, maxWireVersion=7, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=30, roundTripTimeNanos=43838433}
В моем файле сборки нет ничего особенного:
dependencies {
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-data-mongodb-reactive")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-security")
...
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("de.flapdoodle.embed:de.flapdoodle.embed.mongo")
testImplementation("io.projectreactor:reactor-test")
testImplementation("org.springframework.security:spring-security-test")
}
Конфигурация Java в отношении Mongo абсолютно отсутствует, только application.properties
настройки:
spring.data.mongodb.host=localhost
spring.data.mongodb.port=27017
spring.data.mongodb.authentication-database=admin
spring.data.mongodb.database=mydb
spring.data.mongodb.username=myuser
spring.data.mongodb.password=mypass
Что я делаю не так?