-1

enter image description here

enter image description here

Im trying to only do a getmapping for this application and when I go to autowire in the dogservices it says no beans of dog service found. I implement the method header in dogservices and used it dogServicesImpl - Code in pics! Thanks in advance!

Gurwinder Singh
  • 38,557
  • 6
  • 51
  • 76
George
  • 43
  • 5
  • 1
    Hey George. Welcome to Stack Overflow. Please try to post the source code in question as text rather than images so that it is easier to try out while helping you. – Gurwinder Singh Oct 02 '21 at 13:09

1 Answers1

0

Your DogServiceImpl is not decorated with any of the annotations that Spring will use to treat the class as a bean.

Spring will scan everything in your project at its startup, and find classes that are decorated with annotations such as @Component, @Controller and so on. When it finds them, it will handle them in its IoC container, and it will be possible to request an injection with @Autowired.

Your DogServiceImpl is not decorated. It should be annotated with @Service, that is the annotation Spring suggests to use in this case.

Also, you're decorating your controller with @RestController and @Component, but @RestController is an extension of @Controller, that is an extension of @Component, so you only need to use @RestController in your controller.

Gregorio Palamà
  • 1,965
  • 2
  • 17
  • 22