Spring + Maven | 404 Error: The requested resource is not available

Spring + Maven | 404 Error: The requested resource is not available

使用 Eclipse Neon,我遵循简单的 Spring Hello World 教程 here,但我收到 404 错误。这是一个 Maven 项目。

你可以在 GitHub. The project builds, and the server (Tomcat v7.0) starts just fine. But when I go to http://localhost:8080/gs-rest-service/, http://localhost:8080/gs-rest-service/greeting, or http://localhost:8080/greeting 上看到我的代码,我得到了 404 错误。

任何人都可以帮助解释原因,以及如何修复错误吗?

您好,这个项目 (pom) 已经包含内置 tomcat,所以您不需要 运行 在单独的服务器上。只需使用

构建

mvn 全新安装

java -jar target/gs-rest-service-0.1.0-SNAPSHOT.jar

现在检查终点它会起作用。