• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
  • Paul Clapham
Sheriffs:
  • paul wheaton
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Piet Souris
Bartenders:
  • Mike London

Service required a bean of type that could not be found

 
Ranch Hand
Posts: 86
1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm working on a spring boot project (following this tutorial). Consequently, I'm relying on the Apache Derby database to store my data.
When I tried running my spring boot application, I got this error:

***************************
APPLICATION FAILED TO START
***************************

Description:

Field TR in sam.springboot.service.TopicService required a bean of type 'sam.springboot.dao.TopicRepo' that could not be found.

The injection point has the following annotations:
- @org.springframework.beans.factory.annotation.Autowired(required=true)


Action:

Consider defining a bean of type 'sam.springboot.dao.TopicRepo' in your configuration.



Here is my code:

CourseAPIdatabaseApp.java


TopicRepo.java


TopicService.java


TopicController.java


application.properties


pom.xml


What am I missing?

EDIT: here is my project structure by the way:
SpringProjectStructure01.PNG
[Thumbnail for SpringProjectStructure01.PNG]
 
Bartender
Posts: 653
14
TypeScript Fedora
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should run with debug logs.  You will be able to see if its being made and any errors.
 
Bartender
Posts: 2266
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Sam,
Can you try to annotate @EnableJpaRespositories(basePackages="sam.springboot.dao") in the CourseAPIdatabaseApp ?
This way, the repository can be enabled.
 
Himai Minh
Bartender
Posts: 2266
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Sam,
I have a second suggestion. Can you try to rebuild your project? How about right click on the project, select "Maven run..." and put "clean install" in the "Goal" ?
The reason why I am asking because I guess the spring boot data jpa is not on the classpath yet.
 
Himai Minh
Bartender
Posts: 2266
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sam,
One more thing you can try is to remove @Repository from the TopicRepo interface.
 
Himai Minh
Bartender
Posts: 2266
13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, Sam,
One more try is to use embedded h2 database instead of Derby. And also comment out each line of application.properties by adding # in front of each key/value pair.
Run the application and visit localhost:8080/topics

The pom.xml becomes like this:


Give a try to see if it works.
 
reply
    Bookmark Topic Watch Topic
  • New Topic