Skip to content

GH-1763 - Register JDBC event publication auto-configuration for JDBC slice tests. - #1863

Open
dlwhdgus0810 wants to merge 1 commit into
spring-projects:mainfrom
dlwhdgus0810:gh-1763-public-jdbc-autoconfiguration
Open

GH-1763 - Register JDBC event publication auto-configuration for JDBC slice tests.#1863
dlwhdgus0810 wants to merge 1 commit into
spring-projects:mainfrom
dlwhdgus0810:gh-1763-public-jdbc-autoconfiguration

Conversation

@dlwhdgus0810

@dlwhdgus0810 dlwhdgus0810 commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Closes #1763.

Reworked following the suggestion in #1763: instead of making JdbcEventPublicationAutoConfiguration public, the JDBC-specific auto-configuration is now included in the corresponding slice tests out of the box, along the lines of GH-1706. The earlier visibility change is dropped.

  • Adds META-INF/spring/org.springframework.boot.jdbc.test.autoconfigure.AutoConfigureJdbc.imports to spring-modulith-events-jdbc. @AutoConfigureDataJdbc is meta-annotated with @AutoConfigureJdbc, so the single file covers both @JdbcTest and @DataJdbcTest.
  • Lists the Jackson EventSerializer configurations as optional: entries in the same file. The repository cannot be created without a serializer and the JSON auto-configuration is not part of the JDBC slices, so registering the JDBC configuration alone would make @JdbcTest fail to start for anyone with spring-modulith-events-jdbc on the classpath and no serializer in the slice. Both serializer configurations are @ConditionalOnMissingBean(EventSerializer.class), so a serializer declared or mocked in a test still takes precedence. If you would rather have that registration live in spring-modulith-events-jackson, I'm happy to move it.
  • JdbcEventPublicationSliceAutoConfigurationIntegrationTests bootstraps @JdbcTest and @DataJdbcTest configurations through an ApplicationContextRunner, as the Application-module-aware Flyway migrations not activated when Boot's slice test annotations are used #1706 test does, and expects a single EventPublicationRepository and EventSerializer. Both cases fail without the imports file, and fail with No qualifying bean of type 'EventSerializer' without the Jackson entries. The @DataJdbcTest fixture carries @AutoConfigurationPackage, as Spring Data JDBC's repository scanning needs a base package when no @SpringBootApplication is present.
  • Adds spring-boot-data-jdbc-test and spring-modulith-events-jackson as test dependencies of the JDBC module.

…ration for JDBC slice tests.

@jdbcTest and @DataJdbcTest slices did not include
JdbcEventPublicationAutoConfiguration, so no EventPublicationRepository was
available in those tests. We now list it in an AutoConfigureJdbc.imports
file, which @DataJdbcTest picks up through @AutoConfigureJdbc as well.

The Jackson-based EventSerializer configurations are listed as optional
entries, as the repository cannot be created without a serializer and
Boot's JSON auto-configuration is not part of the JDBC slices.

Signed-off-by: Hyun Lee <dlwhdugs4147@gmail.com>
@dlwhdgus0810 dlwhdgus0810 changed the title GH-1763 - Make JdbcEventPublicationAutoConfiguration public. GH-1763 - Register JDBC event publication auto-configuration for JDBC slice tests. Sep 11, 2026
@dlwhdgus0810
dlwhdgus0810 force-pushed the gh-1763-public-jdbc-autoconfiguration branch from cd60799 to 7ff8dfb Compare September 11, 2026 00:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

make JdbcEventPublicationAutoConfiguration class public

1 participant