diff --git a/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java b/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java index ca0ba3b1cc1..b253ac44821 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/config/ConfigFileApplicationListener.java @@ -45,9 +45,9 @@ import org.springframework.boot.env.PropertySourceLoader; import org.springframework.boot.env.RandomValuePropertySource; import org.springframework.boot.logging.DeferredLog; import org.springframework.context.ApplicationEvent; -import org.springframework.context.ApplicationListener; import org.springframework.context.ConfigurableApplicationContext; import org.springframework.context.annotation.ConfigurationClassPostProcessor; +import org.springframework.context.event.SmartApplicationListener; import org.springframework.core.Ordered; import org.springframework.core.annotation.AnnotationAwareOrderComparator; import org.springframework.core.env.ConfigurableEnvironment; @@ -93,7 +93,7 @@ import org.springframework.util.StringUtils; * @author Madhura Bhave */ public class ConfigFileApplicationListener implements EnvironmentPostProcessor, - ApplicationListener, Ordered { + SmartApplicationListener, Ordered { private static final String DEFAULT_PROPERTIES = "defaultProperties"; @@ -140,6 +140,17 @@ public class ConfigFileApplicationListener implements EnvironmentPostProcessor, private int order = DEFAULT_ORDER; + @Override + public boolean supportsEventType(Class eventType) { + return ApplicationEnvironmentPreparedEvent.class.isAssignableFrom(eventType) || + ApplicationPreparedEvent.class.isAssignableFrom(eventType); + } + + @Override + public boolean supportsSourceType(Class aClass) { + return true; + } + @Override public void onApplicationEvent(ApplicationEvent event) { if (event instanceof ApplicationEnvironmentPreparedEvent) { diff --git a/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java b/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java index 306d3171c5e..6f0386098c3 100644 --- a/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java +++ b/spring-boot/src/main/java/org/springframework/boot/context/properties/ConfigurationPropertiesBindingPostProcessor.java @@ -452,7 +452,8 @@ public class ConfigurationPropertiesBindingPostProcessor implements BeanPostProc if (AnnotatedElementUtils.hasAnnotation(type, Validated.class)) { return true; } - if (type.getPackage().getName().startsWith("org.springframework.boot")) { + if (type.getPackage() != null && + type.getPackage().getName().startsWith("org.springframework.boot")) { return false; } if (getConstraintsForClass(type).isBeanConstrained()) {