diff --git a/spring-boot-starter/src/main/java/io/micronaut/spring/boot/starter/MicronautImportRegistrar.java b/spring-boot-starter/src/main/java/io/micronaut/spring/boot/starter/MicronautImportRegistrar.java index afa0b8b07..589a3ab89 100644 --- a/spring-boot-starter/src/main/java/io/micronaut/spring/boot/starter/MicronautImportRegistrar.java +++ b/spring-boot-starter/src/main/java/io/micronaut/spring/boot/starter/MicronautImportRegistrar.java @@ -130,6 +130,7 @@ public void registerBeanDefinitions( ppd.setBeanClass(MicronautPostProcess.class); ppd.setInstanceSupplier(() -> new MicronautPostProcess(context)); registry.registerBeanDefinition("micronautPostProcess", ppd); + genericBeanDefinition.setBeanClass(context.getClass()); genericBeanDefinition.setInstanceSupplier(() -> context); genericBeanDefinition.setDestroyMethodName("stop"); registry.registerBeanDefinition( diff --git a/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java b/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java index 4237ea27d..e2a4f7d45 100644 --- a/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java +++ b/spring-boot-starter/src/test/java/io/micronaut/spring/boot/starter/EnableMicronautTest.java @@ -1,6 +1,8 @@ package io.micronaut.spring.boot.starter; +import java.util.Arrays; import java.util.List; +import java.util.Objects; import io.micronaut.context.ApplicationContext; import io.micronaut.context.annotation.Bean; @@ -15,6 +17,7 @@ import org.springframework.core.env.Environment; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -51,6 +54,12 @@ void testEnableMicronaut() { assertEquals("default", fooBean.getConfiguration().getName()); assertEquals(3, fooBeanList.size()); assertTrue(context.isRunning()); + assertFalse( + context.getAllBeanDefinitions() + .stream() + .map(bean -> bean.getBeanType()) + .anyMatch(Objects::isNull) + ); } }