Merge branch '6.1.x'

This commit is contained in:
Stéphane Nicoll
2024-04-22 15:16:50 +02:00
12 changed files with 214 additions and 63 deletions

View File

@@ -432,7 +432,6 @@ class TestContextAotGeneratorIntegrationTests extends AbstractAotTests {
"org/springframework/test/context/aot/samples/web/WebTestConfiguration__TestContext006_BeanDefinitions.java",
"org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration__TestContext006_Autowiring.java",
"org/springframework/web/servlet/config/annotation/DelegatingWebMvcConfiguration__TestContext006_BeanDefinitions.java",
"org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport__TestContext006_BeanDefinitions.java",
// XmlSpringJupiterTests
"org/springframework/context/event/DefaultEventListenerFactory__TestContext007_BeanDefinitions.java",
"org/springframework/context/event/EventListenerMethodProcessor__TestContext007_BeanDefinitions.java",

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import org.springframework.aot.generate.GenerationContext;
import org.springframework.beans.factory.aot.BeanRegistrationAotContribution;
import org.springframework.beans.factory.aot.BeanRegistrationAotProcessor;
import org.springframework.beans.factory.aot.BeanRegistrationCode;
import org.springframework.beans.factory.support.RegisteredBean.InstantiationDescriptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.aot.ApplicationContextAotGenerator;
@@ -44,7 +45,8 @@ public class ManagementConfiguration {
@Bean
static BeanRegistrationAotProcessor beanRegistrationAotProcessor() {
return registeredBean -> {
Executable factoryMethod = registeredBean.resolveConstructorOrFactoryMethod();
InstantiationDescriptor instantiationDescriptor = registeredBean.resolveInstantiationDescriptor();
Executable factoryMethod = instantiationDescriptor.executable();
// Make AOT contribution for @Managed @Bean methods.
if (AnnotatedElementUtils.hasAnnotation(factoryMethod, Managed.class)) {
return new AotContribution(createManagementContext());