Fix: Error creating bean with name securityConfig: Unsatisfied dependency expressed - NoSuchBeanDefinitionException: No qualifying bean of type

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.

public class DataConfig {
    public DataConfig dataConfig() {
        return new DataConfig();
@ComponentScan(basePackages = "org.code2care")
public class DataApplication {
    public static void main(String[] args) {, args);

Also make sure @Autowired annotation as been added on DataConfig instance.

private DataConfig dataConfig;

And finally, make sure @DependsOn is added on SecurityConfig.

public class SecurityConfig {


Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap