SpringBoot第4小节:数据库操作(下)

这节讲的是springBoot的数据库操作,继承jpa,不用写一条sql语句。

准备:创建一个接口GirlRepository,继承JpaRepository

 准备:创建一个接口GirlRepository,继承JpaRepository

SpringBoot第4小节:数据库操作(下)

接口一:查询列表

1.因为逻辑相对简单,直接在controller调用dto了

SpringBoot第4小节:数据库操作(下)

2.程序运行后,用postman请求,具体返回数据还是得看你的数据库呢。

SpringBoot第4小节:数据库操作(下)

 

接口二:新增

@PostMapping

SpringBoot第4小节:数据库操作(下)

接口三:通过id查询单条数据

@GetMapping

SpringBoot第4小节:数据库操作(下)

接口四:更新 

@PutMapping

SpringBoot第4小节:数据库操作(下)

SpringBoot第4小节:数据库操作(下)

接口五:删除

@DeleteMapping

SpringBoot第4小节:数据库操作(下)

 

转载于:https://my.oschina.net/monroe/blog/1782462

相关文章:

  • 2021-11-12
  • 2023-03-24
  • 2021-12-03
  • 2021-04-19
  • 2021-06-04
  • 2021-08-01
  • 2022-12-23
猜你喜欢
  • 2021-10-07
  • 2021-06-20
  • 2022-12-23
  • 2022-12-23
  • 2021-06-29
  • 2022-01-10
  • 2021-04-14
相关资源
相似解决方案