diff --git a/spring-boot-dependencies/pom.xml b/spring-boot-dependencies/pom.xml
index b0da82904b9..d615c9ff619 100644
--- a/spring-boot-dependencies/pom.xml
+++ b/spring-boot-dependencies/pom.xml
@@ -128,7 +128,7 @@
1.17
5.3.2
1.0-groovy-2.4
- 4.2.5.RELEASE
+ 4.3.0.BUILD-SNAPSHOT
1.6.0.M1
1.2.1.RELEASE
3.0.6.RELEASE
diff --git a/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java b/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java
index 99fa2e55878..0877739dbfb 100644
--- a/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java
+++ b/spring-boot/src/main/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzer.java
@@ -21,6 +21,8 @@ import java.util.List;
import org.springframework.beans.factory.BeanCreationException;
import org.springframework.beans.factory.BeanCurrentlyInCreationException;
+import org.springframework.beans.factory.InjectionPoint;
+import org.springframework.beans.factory.UnsatisfiedDependencyException;
import org.springframework.boot.diagnostics.AbstractFailureAnalyzer;
import org.springframework.boot.diagnostics.FailureAnalysis;
import org.springframework.util.StringUtils;
@@ -34,8 +36,6 @@ import org.springframework.util.StringUtils;
class BeanCurrentlyInCreationFailureAnalyzer
extends AbstractFailureAnalyzer {
- private static final String FIELD_AUTOWIRING_FAILURE_MESSAGE_PREFIX = "Could not autowire field: ";
-
@Override
protected FailureAnalysis analyze(Throwable rootFailure,
BeanCurrentlyInCreationException cause) {
@@ -66,19 +66,18 @@ class BeanCurrentlyInCreationFailureAnalyzer
if (StringUtils.hasText(ex.getResourceDescription())) {
return String.format(" defined in %s", ex.getResourceDescription());
}
- if (causedByFieldAutowiringFailure(ex)) {
- return String.format(" (field %s)",
- ex.getCause().getMessage().substring(
- FIELD_AUTOWIRING_FAILURE_MESSAGE_PREFIX.length(),
- ex.getCause().getMessage().indexOf(";")));
-
+ InjectionPoint failedInjectionPoint = findFailedInjectionPoint(ex);
+ if (failedInjectionPoint != null && failedInjectionPoint.getField() != null) {
+ return String.format(" (field %s)", failedInjectionPoint.getField());
}
return "";
}
- private boolean causedByFieldAutowiringFailure(BeanCreationException ex) {
- return ex.getCause() instanceof BeanCreationException && ex.getCause()
- .getMessage().startsWith(FIELD_AUTOWIRING_FAILURE_MESSAGE_PREFIX);
+ private InjectionPoint findFailedInjectionPoint(BeanCreationException ex) {
+ if (!(ex instanceof UnsatisfiedDependencyException)) {
+ return null;
+ }
+ return ((UnsatisfiedDependencyException) ex).getInjectionPoint();
}
}
diff --git a/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java b/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java
index f68ff6440e1..aaf0eb826ad 100644
--- a/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java
+++ b/spring-boot/src/test/java/org/springframework/boot/diagnostics/analyzer/BeanCurrentlyInCreationFailureAnalyzerTests.java
@@ -57,7 +57,7 @@ public class BeanCurrentlyInCreationFailureAnalyzerTests {
assertThat(analysis.getDescription()).startsWith(
"There is a circular dependency between 3 beans in the application context:");
assertThat(analysis.getDescription()).contains("three defined in "
- + CycleWithAutowiredFields.BeanThreeConfiguration.class);
+ + CycleWithAutowiredFields.BeanThreeConfiguration.class.getName());
assertThat(analysis.getDescription())
.contains("one defined in " + CycleWithAutowiredFields.class.getName());
assertThat(analysis.getDescription())