Files
spring-boot-demo/data-jpa-testcontainers/docs/output/06-autoconfigurejdbc-meta-annotation-javap.txt
Claude 4370ac7fdf Correct post #45: Flyway and Liquibase DO run under @DataJpaTest by default
The previous commit's FlywayDoesNotRunUnderPlainDataJpaTestTest and
FlywayRunsWhenExplicitlyImportedTest rested on a false premise: that none of
@DataJpaTest's four documented meta-annotations import FlywayAutoConfiguration,
so migrations never run under the slice. That reading of the four .imports
manifests is accurate but incomplete. @AutoConfigureJdbc is itself
meta-annotated with @AutoConfigureDataSourceInitialization (new in Boot 4.0),
and Spring's ImportAutoConfigurationImportSelector walks the full
meta-annotation tree transitively. That fifth annotation's own .imports
resource is loaded via ClassLoader.getResources(), which merges same-named
files from every jar on the classpath -- spring-boot-jdbc-test,
spring-boot-flyway and spring-boot-liquibase each ship one at the identical
path, contributing DataSourceInitializationAutoConfiguration,
FlywayAutoConfiguration and LiquibaseAutoConfiguration respectively.

Replaced the two wrong-premise test classes with FlywayRunsByDefaultTest
(proves the bean is present and the migration actually ran) and
ExplicitFlywayImportIsRedundantTest (proves the old "add the import yourself"
advice is harmless but unnecessary on Boot 4.1). Added javap/unzip evidence
for the new mechanism to docs/output, re-captured the full test run (9 tests,
1 clean skip), corrected README's test table, and closed a second,
unrelated gap: the unzip -l listing quoted in the @ServiceConnection section
had no matching captured transcript -- it does now.
2026-10-08 12:35:04 +00:00

41 lines
1.8 KiB
Plaintext

$ javap -v org/springframework/boot/jdbc/test/autoconfigure/AutoConfigureJdbc.class
# unzipped from spring-boot-jdbc-test-4.1.1.jar
RuntimeVisibleAnnotations:
0: #10(#11=[e#12.#13])
java.lang.annotation.Target(
value=[Ljava/lang/annotation/ElementType;.TYPE]
)
1: #14(#11=e#15.#16)
java.lang.annotation.Retention(
value=Ljava/lang/annotation/RetentionPolicy;.RUNTIME
)
2: #17()
java.lang.annotation.Documented
3: #18()
java.lang.annotation.Inherited
4: #19()
org.springframework.boot.autoconfigure.ImportAutoConfiguration
5: #20()
org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization
$ find . -iname '*DataSourceInitialization*' # inside spring-boot-jdbc-test-4.1.1.jar
./META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization.imports
$ cat META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization.imports
org.springframework.boot.jdbc.autoconfigure.DataSourceInitializationAutoConfiguration
# the SAME resource path, inside spring-boot-flyway-4.1.1.jar instead:
$ cat META-INF/spring/org.springframework.boot.test.autoconfigure.jdbc.AutoConfigureDataSourceInitialization.imports
org.springframework.boot.flyway.autoconfigure.FlywayAutoConfiguration
$ javap -v org/springframework/boot/flyway/autoconfigure/FlywayAutoConfiguration.class # unzipped from spring-boot-flyway-4.1.1.jar
#41 = Utf8 Lorg/springframework/boot/autoconfigure/condition/ConditionalOnClass;
#42 = Utf8 value
#43 = Utf8 Lorg/flywaydb/core/Flyway;
#44 = Utf8 Lorg/springframework/context/annotation/Conditional;
--
org.springframework.boot.autoconfigure.condition.ConditionalOnClass(
value=[class Lorg/flywaydb/core/Flyway;]
)
2: #44(#42=[c#45])