Skip to content

Fix datasource prefix in multiple-datasource configuration doc #13915

@membersound

Description

@membersound

https://docs.spring.io/spring-boot/docs/current/reference/html/howto-data-access.html

The example states the following:

@Bean
@Primary
@ConfigurationProperties("app.datasource.first")
public DataSourceProperties firstDataSourceProperties() {
	return new DataSourceProperties();
}

@Bean
@Primary
@ConfigurationProperties("app.datasource.first") //TODO this is wrong.
public DataSource firstDataSource() {
	return firstDataSourceProperties().initializeDataSourceBuilder().build();
}

Problem: the key for the DataSource must be:
app.datasource.first.<datapool name>, eg app.datasource.first.hikari. Only then the properties like app.datasource.first.hikari.minimum-idle will be taken into account.

Likewise for the second ds in the example.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions