• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

Spring Boot REST: can't link bean with service in MVC controller

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good afternoon! I'm new to Java please be patient. I want to get a list of entities via REST, but I can't link bean with service in MVC controller. Below is my code.

Repository


Service interface


Implementation of service interface



REST Controller


This code compiles, but when I call the curl controller I get a message that bin autocoupling has not happened and the object variable points to null.

Curl command


Message from the servlet container


Where is my mistake? Thanks to everyone who replies to this post!
 
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you want that service to be autowired in, then I'm pretty sure you have to annotate it as @Autowired.

Edit: that is, in the Controller.
 
Sergei Prosvirnin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Dave Tolls wrote:If you want that service to be autowired in, then I'm pretty sure you have to annotate it as @Autowired.

Edit: that is, in the Controller.



Thank you, but I have already tried it.
 
Ranch Hand
Posts: 235
1
jQuery Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could you confirm whether Controller & Service are placed in the same package where @SpringBootApplication class in placed ?

I faced this kind of issue once before.
 
Sergei Prosvirnin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mohammed Sardar. wrote:Could you confirm whether Controller & Service are placed in the same package where @SpringBootApplication class in placed ?

I faced this kind of issue once before.



Yes, but the classes are divided into separate sub-packages. I hope very much that I have a problem similar to you.

 
Sergei Prosvirnin
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got answer - https://stackoverflow.com/questions/64803480/spring-boot-rest-app-you-cant-link-bean-with-service-in-mvc-controller
 
Dave Tolls
Rancher
Posts: 4801
50
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't see the Lombok annotation.
 
reply
    Bookmark Topic Watch Topic
  • New Topic