获取404此API

时间:2018-04-22 16:30:18

标签: spring-boot http-status-code-404

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

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

我的要求:

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

接头: 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" }

谢谢!

1 个答案:

答案 0 :(得分:1)

SpringBoot主类扫描“下面”文件夹以查找组件。 您的Application.java与您的组件处于同一级别,因此找不到任何弹簧组件。

重新组织项目的来源如下:

  • COM /项目名称/ Application.java
  • COM /项目名称/控制器/ GreetingController.java
  • COM /项目名称/服务/ GreetingService.java
  • COM /项目名称/型号/...
  • COM /项目名称/ DTO /...
  • COM /项目名称/ DAO /...

此外,当您访问它时,请删除DTO上的@Component