java - Spring-Boot create bean with out name will cause "NoSuchBeanDefinitionException, No qualifying bean of type[]found for dependency " -


i create bean configuration out name

@configuration @configurationproperties(prefix = "mysql") public class dbconfiguration extends basedbconfiguration {    @bean//(name = "fix")   @override   public dbclient createclient() {       return super.createclient();   }  } 

usage:

@autowired private dbclient dbclient; 

when running application can't start up

and throw nosuchbeandefinitionexception:

no qualifying bean of type [dbclient] found dependency: expected @ least 1 bean qualifies autowire candidate dependency. dependency annotations: {@org.springframework.beans.factory.annotation.autowired(required=true)}

but fix add name, why??

@bean(name = "fix") 

i add test such this:

public class testcreate {      @notnull     private int test;      public test createtest() {         return new test(this.test);     }  } 

it configuration this:

@configuration @configurationproperties(prefix = "test") public class testconfiguration extends testcreate {      @override     @bean     public test createtest() {         return super.createtest();     }  } 

and autowired this:

@autowired private test test; 

however, test may work well

it create bean without name , autowired out qualifier

please tell me why....thanks

sorry.

i have found results:

overriding bean definition bean 'createclient': replacing ...

so spring-boot create bean functionname rather returning objectname.


Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -