我正在尝试创建一个 spring webflux 应用程序(java 17),预计:-
从日志中我可以看到服务器已经启动。
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。
我添加了执行器依赖项,但即使这样也不起作用。
我已经被这个问题困扰好几天了。需要一些帮助来解决这个问题。
看起来像是一个依赖性问题。请检查。