Jetty 服务器已启动,但无法访问 api

问题描述 投票:0回答:1

我正在尝试创建一个 spring webflux 应用程序(java 17),预计:-

  1. 监听sqs事件并做一些处理。 (工作正常)
  2. 响应一些配置的api。 (不工作)。

从日志中我可以看到服务器已经启动。

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>

请求后服务器端的日志如下:

https://pastebin.com/JsW5Azu1

这是我的休息控制器类:

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

应用程序.yml

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

management:
    port: 11061
    security:
      enabled: false

应用程序本地.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);
    }

}

pom.xml

https://pastebin.com/A9SrDGNN

我只需要健康检查的api。

我添加了执行器依赖项,但即使这样也不起作用。

我已经被这个问题困扰好几天了。需要一些帮助来解决这个问题。

spring-boot maven jetty spring-webflux spring-boot-actuator
1个回答
0
投票

看起来像是一个依赖性问题。请检查。

© www.soinside.com 2019 - 2024. All rights reserved.