spring.data.mongodb.uri property is ignored
See original GitHub issueHi,
I tried to migrate from Spring Boot 2.3.7.RELEASE
to 2.4.1
:
@Bean
public MongoClientSettings mongoOptions() {
return MongoClientSettings.builder()
.applyToSocketSettings(
builder -> builder.connectTimeout(30, TimeUnit.SECONDS))
.build();
}
When I remove MongoClientSettings
it works, but if I enable it, I got spring.data.mongodb.uri
ignored:
2021-01-04 22:33:30.843+0100 [main] [org.mongodb.driver.cluster] INFO [SLF4JLogger.info:71] - Cluster created with settings {hosts=[127.0.0.1:27017], mode=SINGLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms'}
I tried a workaround by adding connectTimeout=10000
in URI property and I got:
2021-01-04 22:43:07.244+0100 [main] [org.mongodb.driver.cluster] INFO [SLF4JLogger.info:71] - Cluster created with settings {hosts=[xx.xxx.xxx.xxx:27017, xx.xxx.xxx.xxx:27017, xx.xxx.xxx.xxx:27017], mode=MULTIPLE, requiredClusterType=REPLICA_SET, serverSelectionTimeout='30000 ms', requiredReplicaSetName='rs-dev'}
Thanks
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (1 by maintainers)
Top Results From Across the Web
spring boot not using the MongoDB uri in the application ...
In my case, the Spring was ignoring the MongoDB URI from my "production" profile and it always started the embedded mongoDb.
Read more >MongoProperties ignores spring.data.mongodb.uri if any other ...
Spring boot 1.4 I have an app with the following configuration spring.data.mongodb.uri: "mongodb://10.11.22.11:27017/mydb" ...
Read more >Spring Data MongoDB – Configure Connection - Baeldung
In this tutorial, we're going to see different ways to configure a connection to our database. We'll use Spring Boot and Spring Data...
Read more >MongoDB Authentication Failed With Spring Data URI
when I try to connect spring boot application with the mongo-db container then the authentication failed exception has thrown.
Read more >Spring Data MongoDB - Reference Documentation
The Spring Data MongoDB project applies core Spring concepts to the development of solutions that use the MongoDB document style data store.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@aoudiamoncef I confirm you that the given solution works like a charm.
And this spring boot issue