I Create the bean by configuration with 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 I running application it can't start up
And throw NoSuchBeanDefinitionException:
No qualifying bean of type [DbClient] found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
But I fix it by add name, why??
@Bean(name = "fix")
I also add a test such like this:
public class TestCreate {
@NotNull
private int test;
public Test createTest() {
return new Test(this.test);
}
}
it configuration like this:
@Configuration
@ConfigurationProperties(prefix = "test")
public class TestConfiguration extends TestCreate {
@Override
@Bean
public Test createTest() {
return super.createTest();
}
}
And autowired like this:
@Autowired
private Test test;
However, this test may work well
It also create Bean without name and Autowired with out Qualifier
Please Tell me why....thanks