Skip to content

Clarify the javadoc of AutoConfigureTestDatabase to make it clearer that it only replaces the main DataSource #23808

@fransf-wtax

Description

@fransf-wtax

TestDatabaseAutoConfiguration in the getDataSourceBeanDefinition method explicitly only finds for the primary data source to replace it with an embedded datasource.

When running a Spring Boot app with multiple datasources, you might expect all of them to be replaced with embedded datasources. It would be helpful if a message was logged for all non-primary data sources found explaining that they were not replaced because only replacing the primary data source is supported, possible with a reference to documentation explaining what the recommended approach is in the multiple-datasource scenario.

Also, the Javadoc for @AutoConfigureTestDatabase is somewhat misleading here:

 /**
 * Replace any DataSource bean (auto-configured or manually defined).
 */
ANY,

Actually, not "any" data source is replaced; only a single data source annotated as (or implicitly) @Primary.

Happy to submit pull requests for all of the above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions