【问题标题】:Default value of parameter not returned in Response Object响应对象中未返回参数的默认值
【发布时间】:2017-09-02 03:24:25
【问题描述】:

我正在使用 SpringBoot 学习 WebServices。

我遇到了这个例子spring-actuator-service

控制台日志显示以下内容

2017-04-07 03:04:59.281  INFO 13024 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 9001 (http)
2017-04-07 03:04:59.290  INFO 13024 --- [           main] o.s.c.support.DefaultLifecycleProcessor  : Starting beans in phase 0
2017-04-07 03:04:59.548  INFO 13024 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 9000 (http)
2017-04-07 03:04:59.555  INFO 13024 --- [           main] hello.HelloWorldConfiguration            : Started HelloWorldConfiguration in 8.274 seconds (JVM running for 9.183)

当我将应用程序作为 Spring Boot 应用程序运行并进入

http://localhost:9001/hello-world

我在屏幕上得到的响应如下。

{"timestamp":1491514947950,"status":404,"error":"Not Found","message":"No message available","path":"/hello-world"}

谁能帮我理解为什么我没有得到响应

{"id":1,"content":"Hello, Stranger!"}

【问题讨论】:

  • 该示例提到curl http://localhost:9000/hello-world 以获得预期的答案,但您显然使用了端口 9001。或者它是一个错字?

标签: java json spring-boot


【解决方案1】:

端口 9001 是 actuator 端点(健康指标和类似的)。端口 9000 是您的应用程序的内容,HelloWorldController 所在的位置。如文档中和@Marc Tarin 所述,请使用http://localhost:9000/hello-world

【讨论】:

    猜你喜欢
    • 2011-04-05
    • 1970-01-01
    • 2014-08-18
    • 2012-08-03
    • 1970-01-01
    • 1970-01-01
    • 2020-12-22
    • 1970-01-01
    • 2022-11-03
    相关资源
    最近更新 更多