diff --git a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySource.java b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySource.java index 1994303645ef..d52cc0c8d51b 100644 --- a/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySource.java +++ b/spring-boot-project/spring-boot-testcontainers/src/main/java/org/springframework/boot/testcontainers/properties/TestcontainersPropertySource.java @@ -115,7 +115,7 @@ private static DynamicPropertyRegistry attach(Environment environment, Applicati if (eventPublisher != null) { propertySource.addEventPublisher(eventPublisher); } - else if (registry != null) { + else if (registry != null && !registry.containsBeanDefinition(EventPublisherRegistrar.NAME)) { registry.registerBeanDefinition(EventPublisherRegistrar.NAME, new RootBeanDefinition( EventPublisherRegistrar.class, () -> new EventPublisherRegistrar(environment))); }