question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

spring.data.mongodb.uri property is ignored

See original GitHub issue

Hi,

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:closed
  • Created 3 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
antechrestoscommented, May 3, 2021

@aoudiamoncef I confirm you that the given solution works like a charm.

0reactions
antechrestoscommented, May 3, 2021
Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found