From 971a7194d8292fab345b9438bfda8030749f38d3 Mon Sep 17 00:00:00 2001 From: Rob Baily Date: Mon, 28 Mar 2016 09:46:31 -0400 Subject: [PATCH] Add check for non empty list of factories It was seeen that if a different plugin was used to package Spring Boot that the project would load but no autoconfiguration actually took place and many features were mysteriously not working. Adding a check to ensure that some factories are always loaded as this is expected. Closes gh-5465 --- .../autoconfigure/EnableAutoConfigurationImportSelector.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java index cdb012b4d1c..2513f2e84c8 100644 --- a/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java +++ b/spring-boot-autoconfigure/src/main/java/org/springframework/boot/autoconfigure/EnableAutoConfigurationImportSelector.java @@ -140,8 +140,11 @@ public class EnableAutoConfigurationImportSelector */ protected List getCandidateConfigurations(AnnotationMetadata metadata, AnnotationAttributes attributes) { - return SpringFactoriesLoader.loadFactoryNames( + List configurations = SpringFactoriesLoader.loadFactoryNames( getSpringFactoriesLoaderFactoryClass(), getBeanClassLoader()); + Assert.notEmpty(configurations, + "No auto configuration factories available. Please check your packaging to assure that the META-INF/spring.factories file is correct."); + return configurations; } /**