gs-accessing-data-mongodb: Getting error - Field repository in hello.Application required a bean of type 'hello.CustomerRepository' that could not be found.

Thanks very nice tutorial.

I have cloned the project and when trying to nun Application.java as SpringBoot application gets the below error. CustomerRepositoryTests.java also gives the same error.

. ____ _ __ _ _ /\ / __ _ () __ __ _ \ \ \
( ( )_
_ | '_ | '| | ’ / ` | \ \ \
\/ )| |)| | | | | || (| | ) ) ) ) ’ |
| .__|| ||| |_, | / / / / =========||==============|/=//// :: Spring Boot :: (v1.5.7.RELEASE)

2017-10-15 21:24:07.546 INFO 819 — [ main] hello.Application : Starting Application on Jayakumars-iMac with PID 819 (/Users/jay/git/gs-accessing-data-mongodb/complete/target/classes started by jay in /Users/jay/git/gs-accessing-data-mongodb/complete) 2017-10-15 21:24:07.547 INFO 819 — [ main] hello.Application : No active profile set, falling back to default profiles: default 2017-10-15 21:24:07.571 INFO 819 — [ main] s.c.a.AnnotationConfigApplicationContext : Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@23bb8443: startup date [Sun Oct 15 21:24:07 BST 2017]; root of context hierarchy 2017-10-15 21:24:07.806 WARN 819 — [ main] s.c.a.AnnotationConfigApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘application’: Unsatisfied dependency expressed through field ‘repository’; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type ‘hello.CustomerRepository’ available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)} 2017-10-15 21:24:07.810 INFO 819 — [ main] utoConfigurationReportLoggingInitializer :

Error starting ApplicationContext. To display the auto-configuration report re-run your application with ‘debug’ enabled. 2017-10-15 21:24:07.867 ERROR 819 — [ main] o.s.b.d.LoggingFailureAnalysisReporter :


APPLICATION FAILED TO START


Description:

Field repository in hello.Application required a bean of type ‘hello.CustomerRepository’ that could not be found.

Action:

Consider defining a bean of type ‘hello.CustomerRepository’ in your configuration.

About this issue

  • Original URL
  • State: closed
  • Created 7 years ago
  • Comments: 32 (4 by maintainers)

Most upvoted comments

Getting same error in Spring boot version (v2.0.3.RELEASE)

Just add @EnableFeignClients annotation in your main springboot application class (where you annotate @SpringBootApplication). This will work.

Hey Folks,

So I resolved my issue, your mileage may vary…I had a minor configuration issue on my end in application.properties…

I can now confirm this works v2.0.6.RELEASE works on OSX 10.14 with Java 1.8.

Can you share the configuration you changed? I am also facing the issue in demo application and I don’t have anything in application.properties.

Facing same issue with v2.0.5.RELEASE