Skip to content

Add support for configuring the Redis database using spring.data.redis.url #43810

@Demonese

Description

@Demonese

Both Jedis and Lettese clients support specifying a database in the URL

Unfortunately, spring-boot-autoconfigure ignore them

	@Override
	public Standalone getStandalone() {
		if (this.properties.getUrl() != null) {
			ConnectionInfo connectionInfo = connectionInfo(this.properties.getUrl());
			return Standalone.of(connectionInfo.getUri().getHost(), connectionInfo.getUri().getPort(),
					this.properties.getDatabase());
		}
		return Standalone.of(this.properties.getHost(), this.properties.getPort(), this.properties.getDatabase());
	}

This causes the following URL actually connect to database 0

spring:
  data:
    redis:
      url: redis://127.0.0.1:6379/8

The current workaround in my project is

spring:
  data:
    redis:
      url: redis://127.0.0.1:6379/8
      database: 8

: (

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions