Error creating bean with name 'securityConfig':
Unsatisfied dependency expressed through field 'dataConfig';
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No qualifying bean of type 'org.code2care.DataConfig' available:
expected at least 1 bean which qualifies as autowire candidate.
Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
You get this error due to an issue with Spring Framework related to dependency injection, there seems to be a problem with autowiring a bean of type org.code2care.DataConfig in your SecurityConfig class.
Make sure the below classes are defined correctly.
@Configuration
public class DataConfig {
@Bean
public DataConfig dataConfig() {
return new DataConfig();
}
}
@SpringBootApplication
@ComponentScan(basePackages = "org.code2care")
public class DataApplication {
public static void main(String[] args) {
SpringApplication.run(DataApplication.class, args);
}
}
Also make sure @Autowired annotation as been added on DataConfig instance.
@Autowired
private DataConfig dataConfig;
And finally, make sure @DependsOn is added on SecurityConfig.
@Configuration
@DependsOn("dataConfig")
public class SecurityConfig {
...
...
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!