得到一个 404 API

Getting a 404 to this API

我这里有一个API:https://github.com/BillyCharter87/Tech-O-Dex-API/tree/AddingSpringJPA

我在 /greeting/health 上继续收到 404。该应用程序启动正常并部署在 8080 上,我也尝试将侦听器端口更改为其他端口但无济于事。

我的要求:

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

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

我得到的回复: { "timestamp": "2018-04-22T16:20:30.874+0000", "status": 404, "error": "Not Found", "message": "No message available", "path": "/greeting" }

谢谢!

SpringBoot main class扫描文件夹"below"寻找组件。 您的 Application.java 与您的组件处于同一级别,因此找到了 spring 个组件中的 none 个。

按如下方式重新组织项目的源代码:

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

此外,在您使用它的同时,删除 DTO 上的 @Component