【发布时间】:2018-03-24 16:45:34
【问题描述】:
我有提供一些 REST API 的 Spring Boot (2.0.0 M5) 应用程序。我想使用RouterFunctions 来实现这个 API。
当我使用嵌入式 Jetty 运行应用程序时,一切正常。
当我将应用程序转换为 WAR 文件(遵循 documentation here)并将其部署到 Tomcat 8.5 时,尝试调用任何端点时总是得到 404。
我可以在日志中看到端点被识别:
[ost-startStop-1] s.w.r.r.m.a.RequestMappingHandlerMapping : Mapped "{[/say-hello],methods=[GET]}" onto java.lang.String com.example.demo.DemoController.test()
[ost-startStop-1] o.s.w.r.f.s.s.RouterFunctionMapping: Mapped /api => {
/v1 => {
/status ->
com.example.demo.DemoApplication$$Lambda$189/1904651750@5fdc83e
}
}
但是当调用curl -v http://localhost:8080/demo/say-hello 或curl -v http://localhost:8080/demo/api/v1/status 时,我看到了默认的Tomcat 404 页面。路径是正确的,我在部署之前将.war重命名为demo.war。
有人遇到过类似的问题吗?您可以找到代码here。
【问题讨论】:
-
有什么错误吗?你检查过 Tomcat 控制台是否有错误?
-
是的,我做到了。没有错误。 :-(
标签: java spring-boot spring-webflux