Billy
Billy

Reputation: 1067

Getting a 404 to this API

I have an API here: https://github.com/BillyCharter87/Tech-O-Dex-API/tree/AddingSpringJPA

I continue to get a 404 on either the /greeting or /health. The application starts up fine and deploys on 8080, I've also tried changing the listener port to something else but to no avail.

My Request:

{ "firstName": "Billy", "lastName": "Charter" }

Headers: Content-Type: application/json Accept: application/json

Response I get back: { "timestamp": "2018-04-22T16:20:30.874+0000", "status": 404, "error": "Not Found", "message": "No message available", "path": "/greeting" }

Thanks!

Upvotes: 0

Views: 59

Answers (1)

alexbt
alexbt

Reputation: 17025

SpringBoot main class scans the folder "below" to find components. Your Application.java is at the same level as your components, so none of your spring components are found.

Reorganize your project's sources as follow:

  • com/projectname/Application.java
  • com/projectname/controller/GreetingController.java
  • com/projectname/service/GreetingService.java
  • com/projectname/model/...
  • com/projectname/dto/...
  • com/projectname/dao/...

Also, while you're at it, remove the @Component on your DTO.

Upvotes: 1

Related Questions