Skip to content

Restore service connections in AOT-processed tests#50958

Open
goutamadwant wants to merge 1 commit into
spring-projects:mainfrom
goutamadwant:fix-service-connection-aot
Open

Restore service connections in AOT-processed tests#50958
goutamadwant wants to merge 1 commit into
spring-projects:mainfrom
goutamadwant:fix-service-connection-aot

Conversation

@goutamadwant

Copy link
Copy Markdown

Summary

Using @ServiceConnection on a Testcontainers @Bean method does not provide connection details when an AOT-processed test runs. The connection-details bean definitions use instance suppliers, so they are excluded from AOT processing, but unlike field-based service connections there is no test context customizer to recreate them at runtime.

This change registers AOT-processable connection-details bean definitions for @Bean-based container sources. At runtime, the connection details are recreated from the container bean and its factory method metadata, including annotations such as @Ssl. Field-based service connections retain their existing registration path.

Tests cover generating and running an AOT-processed test context and verify that the expected connection details and source annotations are available.

Fixes #42851.

Signed-off-by: goutamadwant <workwithgoutam@gmail.com>
@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: waiting-for-triage An issue we've not yet triaged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Using @ServiceConnection on a Container @Bean method does not work with AOT-processed tests

2 participants