spring - 在 Spring 中尝试对控制器进行 REST GET 调用时出现 404 错误
问题描述
我正在尝试使用 Spring 对本地 Tomcat9 服务器进行 REST 调用。我的控制器如下。
@RestController
public class HelloWorldController {
@RequestMapping(method=RequestMethod.GET, path="/hello-world")
public String helloWorld() {
return "Hello World";
}
}
但是,当我尝试使用 url 进行 REST 请求时http://localhost:8080/hello-world
,我收到以下 404 错误:
The origin server did not find a current representation for the target resource or is not willing to disclose that one exists.
我该如何解决这个问题?我正在尝试使用 Spring 进行更多练习。
编辑:我解决了这个问题。我停止了 Tomcat 服务器并将 RestfulWebServicesApplication 作为 Java 应用程序运行。
解决方案
推荐阅读
- python - gspread 和 google sheet api 不会从 google sheet 中读取一个单元格并给我超时错误
- python - python multiprocessing pool.map() 等到方法完成
- javascript - 如何将 nuxt.config.js 中的 .env 值与运行时配置一起使用
- javascript - 未捕获的类型错误:无法读取未定义的属性(读取“拆分”)
- javascript - 如何在同一个按钮上使用反应路由器和反应滚动?
- python - 烧瓶检查用户是否选择了要上传的文件
- powershell - Powershell - 具有多个系列的图表
- node.js - TypeORM 用外键插入行
- python-3.x - 编译此代码时出现此错误“超出时间限制,您的程序花费的时间比预期的要多。”
- java - 带有 Thymeleaf、BindingResult 或 bean 名称“用户”的普通目标对象的 Spring 可用作请求属性