Skip to content

spring.data.mongodb.uri property is ignored #3531

@aoudiamoncef

Description

@aoudiamoncef

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fix

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions