【问题标题】:Maven build is successfull but still getting 404 error Not foundMaven 构建成功但仍然出现 404 错误 Not found
【发布时间】:2020-05-28 13:08:36
【问题描述】:

所以我正在尝试执行https://spring.io/guides/gs/rest-service/#scratch 指南,并且我正在通过在目标选项中使用全新安装“运行为”“maven build”来安装 maven 项目。我不知道是什么问题。我也在使用 m2e 插件来运行 maven 构建,因为我搜索了其他人的答案,人们说使用 eclipse maven 命令行很糟糕。

但我在http://localhost:8080/greeting 的浏览器中收到此错误

HTTP 状态 404 – 未找到 输入状态报告

留言/问候

描述 源服务器没有找到目标资源的当前表示或不愿意透露存在。

Apache Tomcat/9.0.31

构建成功:

https://pastebin.com/QJtxyjxV

我已将其粘贴在这里,因为堆栈溢出将其标记为垃圾邮件,并且我再次粘贴了几行代码,因为链接未被接受:/

mockHttpServletRequest:
      HTTP Method = GET
      Request URI = /greeting
       Parameters = {}
          Headers = []
             Body = null
    Session Attrs = {}

Handler:
             Type = com.example.restservice.GreetingController
           Method = com.example.restservice.GreetingController#greeting(String)

Async:
    Async started = false
     Async result = null

Resolved Exception:
             Type = null

ModelAndView:
        View name = null
             View = null
            Model = null

FlashMap:
       Attributes = null

MockHttpServletResponse:
           Status = 200
    Error message = null
          Headers = [Content-Type:"application/json"]
     Content type = application/json
             Body = {"id":1,"content":"Hello, World!"}
    Forwarded URL = null
   Redirected URL = null
          Cookies = []

MockHttpServletRequest:
      HTTP Method = GET
      Request URI = /greeting
       Parameters = {name=[Spring Community]}
          Headers = []
             Body = null
    Session Attrs = {}

Handler:
             Type = com.example.restservice.GreetingController
           Method = com.example.restservice.GreetingController#greeting(String)

Async:
    Async started = false
     Async result = null

Resolved Exception:
             Type = null

ModelAndView:
        View name = null
             View = null
            Model = null

FlashMap:
       Attributes = null

MockHttpServletResponse:
           Status = 200
    Error message = null
          Headers = [Content-Type:"application/json"]
     Content type = application/json
             Body = {"id":2,"content":"Hello, Spring Community!"}
    Forwarded URL = null
   Redirected URL = null
          Cookies = []

【问题讨论】:

标签: java spring spring-boot maven spring-mvc


【解决方案1】:

除了 maven build,运行启动应用程序的 spring boot 应用程序类。在项目级别运行以下命令。

mvn spring-boot:run

如果您使用任何 IDE,请右键单击 Spring boot Application 类并调用“Run Application”。

【讨论】:

    猜你喜欢
    • 2016-10-03
    • 2017-09-03
    • 1970-01-01
    • 1970-01-01
    • 2018-07-19
    • 1970-01-01
    • 2017-06-08
    • 1970-01-01
    • 2012-06-17
    相关资源
    最近更新 更多