This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
Win a copy of OCP Oracle Certified Professional Java SE 11 Programmer I Study Guide: Exam 1Z0-815 this week in the Programmer Certification forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Junilu Lacar
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Knute Snortum
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Paweł Baczyński
  • Piet Souris
  • Vijitha Kumara

Service required a bean of type that could not be found

 
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • 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]
 
Rancher
Posts: 506
6
IntelliJ IDE Spring Fedora
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should run with debug logs.  You will be able to see if its being made and any errors.
 
Ranch Hand
Posts: 1769
12
  • Mark post as helpful
  • send pies
  • 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
Ranch Hand
Posts: 1769
12
  • Mark post as helpful
  • send pies
  • 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
Ranch Hand
Posts: 1769
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Sam,
One more thing you can try is to remove @Repository from the TopicRepo interface.
 
Himai Minh
Ranch Hand
Posts: 1769
12
  • Mark post as helpful
  • send pies
  • 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.
 
I have a knack for fixing things like this ... um ... sorry ... here is a consilitory tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!