I have noticed this error in Spring Boot 1.3.3 Release only. This wasn't the problem in 1.3.2 and prior. Following is the exception trace that started occurring now. FYI I am not using Spring Boot's method of creating JDBC datasource due to custom encryption around credentials. Instead there is a Spring configuration class that manually composes the instance of HikariCP DataSource.
2016-02-27 13:52:17,257 [ERROR] [Logger::o.s.b.SpringApplication] [Thread::restartedMain] - Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'inMemoryDatabaseShutdownExecutor' defined in class path resource [org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 1 of type [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties]: No qualifying bean of type [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:464)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)
at com.myapp.MywebApplication.main(MywebApplication.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 24 common frames omitted
Comment From: wilkinsona
@sachinwalia2k8 It looks like you must have excluded DataSourceAutoConfiguration
. You can probably work around the problem by either adding @EnableConfigurationProperties(DataSourceProperties.class)
to a configuration class of your own, or by removing the exclusion (your DataSource will cause the auto-configuration to back off anyway).
Comment From: sachin-walia
@wilkinsona - for now I have excluded devtools from my pom file and things are working. To me it seems like a regression as same code works without modification with 1.3.2 release. I will try the workaround you mentioned.
Comment From: wilkinsona
To me it seems like a regression as same code works without modification with 1.3.2 release
You are correct. The issue is already labelled as such. I was simply describing my understanding of what you must have done, and suggesting a couple of possible ways to avoid the problem while still being able to use Dev Tools.
Comment From: mandado
I have same error, how i can to solve this ?
Comment From: philwebb
@mandado The fix has not been released yet, you can try the snapshot build.
Comment From: mandado
@philwebb have any forecast for next release this fix ?
Comment From: philwebb
Not as yet no, we currently only have 15 issues resolved in 1.3.4.
Comment From: mandado
thanks :+1:
Comment From: sachin-walia
@mandado for now if you exclude devtools then it'd work. it's a pain though since class auto reloading will not work.
Comment From: wilkinsona
@mandado Please see my comment above for a couple of possible work arounds, both of which I think are preferable to removing DevTools.
Comment From: mmoayyed
We are also affected by this. Seems like per the schedule outlined here: https://github.com/spring-projects/spring-boot/milestones , we can upgrade to 1.3.4 and the problem should go away, is that correct? 1.3.4 coming out today?
Comment From: wilkinsona
@mmoayyed It won't be today. We're waiting from Spring Framework 4.2.6 to be released. It's scheduled for tomorrow.
Comment From: mmoayyed
Excellent. Thanks.
Comment From: sing1ee
I had use these versions:
ext {
springBootVersion = "1.3.4.RELEASE"
springVersion = "4.2.6.RELEASE"
jacksonVersion = "2.5.3"
reactorVersion = '2.0.4.RELEASE'
}
but, I still got this error:
08:46:08 [restartedMain] ERROR o.s.boot.SpringApplication - Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'inMemoryDatabaseShutdownExecutor' defined in class path resource [org/springframework/boot/devtools/autoconfigure/DevToolsDataSourceAutoConfiguration.class]: Unsatisfied dependency expressed through constructor argument with index 1 of type [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties]: No qualifying bean of type [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:749)
at org.springframework.beans.factory.support.ConstructorResolver.instantiateUsingFactoryMethod(ConstructorResolver.java:464)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:1123)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:1018)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:510)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:482)
at org.springframework.beans.factory.support.AbstractBeanFactory$1.getObject(AbstractBeanFactory.java:306)
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:230)
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:302)
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:197)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:772)
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:839)
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:538)
at org.springframework.boot.context.embedded.EmbeddedWebApplicationContext.refresh(EmbeddedWebApplicationContext.java:118)
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:766)
at org.springframework.boot.SpringApplication.createAndRefreshContext(SpringApplication.java:361)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:307)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191)
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180)
at com.example.WebApplication.main(WebApplication.java:29)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at org.springframework.boot.devtools.restart.RestartLauncher.run(RestartLauncher.java:49)
Caused by: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type [org.springframework.boot.autoconfigure.jdbc.DataSourceProperties] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {}
at org.springframework.beans.factory.support.DefaultListableBeanFactory.raiseNoSuchBeanDefinitionException(DefaultListableBeanFactory.java:1373)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1119)
at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1014)
at org.springframework.beans.factory.support.ConstructorResolver.resolveAutowiredArgument(ConstructorResolver.java:813)
at org.springframework.beans.factory.support.ConstructorResolver.createArgumentArray(ConstructorResolver.java:741)
... 24 common frames omitted
Comment From: philwebb
@sing1ee I wonder if your build isn't picking up the correct Spring Boot version. Check the output of gradle dependencies
. If you're still getting the issue could you please raise a new issue and provide a project that replicates the problem.
Comment From: sing1ee
@philwebb Thank you. I found the springboot still depended the 4.2.5 spring~, not 4.2.6. Thank you.
Comment From: fxavier
I'm facing the same problem so how to fix it?
Comment From: wilkinsona
@fxavier The original problem described in this issue should be fixed in Spring Boot 1.3.4.RELEASE. If you're using 1.3.4 or later and still have this problem, please open a new issue with details of how to recreate it. A small sample project would be ideal.
Comment From: omeryounus
Hi, I have got the same error in 1.4.1 stable release. Is there any work around?
Comment From: wilkinsona
@omeryounus The original problem described in this issue should be fixed in Spring Boot 1.3.4.RELEASE. If you're using 1.4.1 and still have this problem, please open a new issue with details of how to recreate it. A small sample project would be ideal.
Comment From: anthony-coplo
Hi, I have got the same error in the 1.5.9 release.
how can i fix it ??
Comment From: wilkinsona
@gamerkilli Please see the comment immediately above yours. The same applies to 1.5.9.
Comment From: yasmine1996mira
i have the same error in the 2.1.14 release.
Comment From: wilkinsona
@yasmine1996mira Can you please open a new issue and provide us with a small sample project that reproduces the problem? You can do so by pushing it to a separate repository on GitHub or by zipping it up and attaching it to the issue that you create.