From 26741d8044c7f3003355ac1f07b20f8b13ebd845 Mon Sep 17 00:00:00 2001 From: Moritz Halbritter Date: Tue, 19 Jul 2022 16:07:10 +0200 Subject: [PATCH] Register SpringApplication on ReflectionHints for binding Closes gh-31534 --- .../org/springframework/boot/SpringApplication.java | 13 +++++++++++++ .../main/resources/META-INF/spring/aot.factories | 1 + 2 files changed, 14 insertions(+) diff --git a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java index da3874b660..5f9d7afa04 100644 --- a/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java +++ b/spring-boot-project/spring-boot/src/main/java/org/springframework/boot/SpringApplication.java @@ -33,6 +33,8 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.springframework.aot.AotDetector; +import org.springframework.aot.hint.RuntimeHints; +import org.springframework.aot.hint.RuntimeHintsRegistrar; import org.springframework.beans.BeansException; import org.springframework.beans.CachedIntrospectionResults; import org.springframework.beans.factory.config.BeanDefinition; @@ -45,6 +47,7 @@ import org.springframework.beans.factory.support.BeanNameGenerator; import org.springframework.beans.factory.support.DefaultListableBeanFactory; import org.springframework.beans.factory.xml.XmlBeanDefinitionReader; import org.springframework.boot.Banner.Mode; +import org.springframework.boot.context.properties.ConfigurationPropertiesReflectionHintsRegistrar; import org.springframework.boot.context.properties.bind.Bindable; import org.springframework.boot.context.properties.bind.Binder; import org.springframework.boot.context.properties.source.ConfigurationPropertySources; @@ -1390,4 +1393,14 @@ public class SpringApplication { } + static class SpringApplicationRuntimeHints implements RuntimeHintsRegistrar { + + @Override + public void registerHints(RuntimeHints hints, ClassLoader classLoader) { + ConfigurationPropertiesReflectionHintsRegistrar.processConfigurationProperties(SpringApplication.class, + hints.reflection()); + } + + } + } diff --git a/spring-boot-project/spring-boot/src/main/resources/META-INF/spring/aot.factories b/spring-boot-project/spring-boot/src/main/resources/META-INF/spring/aot.factories index f4f3db0a89..7f5bbaa03e 100644 --- a/spring-boot-project/spring-boot/src/main/resources/META-INF/spring/aot.factories +++ b/spring-boot-project/spring-boot/src/main/resources/META-INF/spring/aot.factories @@ -4,6 +4,7 @@ org.springframework.boot.env.PropertySourceRuntimeHints,\ org.springframework.boot.json.JacksonRuntimeHints,\ org.springframework.boot.logging.java.JavaLoggingSystemRuntimeHints,\ org.springframework.boot.logging.logback.LogbackRuntimeHints,\ +org.springframework.boot.SpringApplication.SpringApplicationRuntimeHints,\ org.springframework.boot.WebApplicationType.WebApplicationTypeRuntimeHints org.springframework.beans.factory.aot.BeanFactoryInitializationAotProcessor=\