【问题标题】:Spring Boot Application ,JPA,Spring Boot 应用程序,JPA,
【发布时间】:2020-12-21 16:59:10
【问题描述】:

我使用 Spring Boot 框架创建了一个小应用程序。我创建了一个 Rest Controler 类。 并将其部署在 tomcat 上,但我收到 404 错误,即 源服务器没有找到目标资源的当前表示或不愿意透露存在。

@RestController

@RequestMapping("学生") 公共类 StudentController {

@Autowired
StudentRepository repository;

@GetMapping
public List<Student> getAllStudents() {
    return (List<Student>) repository.findAll();
}

@PostMapping
public String createStudent() {
    return "created";
}

@PutMapping
public String updateStudent() {
    return "updated";
}

@DeleteMapping
public String deleteStudent() {
    return "deleted";
}

}

【问题讨论】:

    标签: spring-boot rest jpa http-status-code-404 tomcat9


    【解决方案1】:

    注释中缺少斜线,应该是这样的

    @RestController
    @RequestMapping("/students")
    public class StudentController {
       ...
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-10-19
      • 1970-01-01
      • 2020-12-09
      • 2016-10-12
      • 2018-09-17
      • 2018-08-17
      • 2020-06-11
      • 2023-03-16
      相关资源
      最近更新 更多