0

I am new to spring boot and want to design my own APIs and test them with Postman client. However, I can't get past the following error.

enter image description here

Any opinions on this one? I found similar topics but none of them fix my problem.

I also give you my controller, model, and service classes.

enter image description here

enter image description here

enter image description here

I believe I clearly initialized LectureService reference by using @Autowired annotation. This error keeps bugging me.

Note: I also added

@SpringBootApplication(scanBasePackages = {
        "io.theBMan.springBootStarter.lecture"
})

to my App.java class but didn't help as well.

Burakhan Aksoy
  • 319
  • 3
  • 14

1 Answers1

1

Adding the answer here as Simon suggested.

You've autowired the service inside controller code but have not annotated the service class with @Service. That is the cause of this issue.

Note: The following stackoverflow answer beautifully explains about how and why both classes ( in your case LectureService and LectureController) should be defined to live in the application context. It is an excellent read.

Kavitha Karunakaran
  • 1,340
  • 1
  • 17
  • 32