【发布时间】:2021-08-05 18:29:36
【问题描述】:
我在 Eclipse 中创建了一个简单的 Spring Boot 应用程序,它具有 User 类,并且我编写了 Web 服务来对 User 执行各种操作,例如 get-users、create-user、delete-user。
当我从浏览器测试应用程序时,我收到以下错误: 此应用程序没有显式映射 /error,因此您将其视为后备。
我使用的路径:http://localhost:8080/user/get-user/Mike 我已经注释了用户资源类@RestController 和应用程序类@SpringBootApplication。
代码 sn-p:
@RequestMapping(method = RequestMethod.GET, path = "/user/get-user/{name}" )
public User getUserByName(@PathVariable String name) {
System.out.println("Request for name: "+name);
return service.getUser(name); // this return the first user found with given name
}
这是我的项目结构: Project Structure
【问题讨论】:
标签: java spring spring-boot microservices