You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Jetty已启动但Spring WebFlux API及Actuator接口无法访问求助

Spring WebFlux应用API 404问题排查请求

问题概述

  • 基于Java 17构建的Spring WebFlux应用,监听SQS事件功能正常,但配置的API接口无法响应,返回404错误
  • 已添加Actuator依赖,健康检查接口同样无法访问

现象细节

服务器启动日志

2023-12-09 10:24:10.537  INFO 69447 --- [           main] o.s.b.web.embedded.jetty.JettyWebServer  : Jetty started on port(s) 11060 (http/1.1) with context path '/'

请求测试结果

执行请求命令:curl --location 'localhost:11060/api/get',收到404错误响应:

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
<title>Error 404 Not Found</title>
</head>
<body><h2>HTTP ERROR 404</h2>
<p>Problem accessing /api/get. Reason:
<pre>    Not Found</pre></p>
</body>
</html>

相关代码与配置

RestController实现

@RestController
@RequestMapping("/api")
public class RestApi {
    @GetMapping("/get")
    public String get(){
        return "OK";
    }
}

application.yml配置

spring:
  profiles:
    active: local
server:
  port: 11060

management:
    port: 11061
    security:
      enabled: false

application-local.yml配置

server:
  port: 11060

logging:
  level:
    root: DEBUG
    org:
      springframework: DEBUG

主启动类代码

@SpringBootApplication
        (exclude = org.springframework.boot.autoconfigure.web.embedded.EmbeddedWebServerFactoryCustomizerAutoConfiguration.class)
@EnableConfigurationProperties(S3Configuration.class)
@ComponentScan(basePackages = {
        "in.name.consumers.*",
        "in.name.consumers.controller.*",
})
@EnableSqsWithRetry
public class NameConsumer {
    public static void main(String[] args)
    {
        SpringApplication.run(NameConsumer.class, args);
    }
}

内容的提问来源于stack exchange,提问作者Saurabh Choudhary

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.04 18:02:44