初学SpringBoot笔记
来源:互联网 发布:网校视频下载软件 编辑:程序博客网 时间:2024/05/29 10:41
微服务是当前非常流行的架构,解决方案
- spring家族为微服务架构提供了一整套的组件(component),叫做springCloud
- springBoot为springCloud的基础.
搭建springboot环境的时候,yml文件没有提示
- 因为我名字写错了,应该写application.yml
- 没有写对名字是不会自动提示的
实体类注解 ,报错了No identifier specified for entity
- @id要用javax.persistence包下的
Controller中crud
@RestControllerpublic class CaserController {@Autowiredprivate CaserRepository mCaserRepository;@GetMapping(value="/caser")public List<Caser> caserList(){ return mCaserRepository.findAll();}@PostMapping(value = "/addCaser")public Caser girlAdd(@RequestParam("age")Integer age,@RequestParam("name")String name){ Caser caser=new Caser(); caser.setAge(age); caser.setName(name);return mCaserRepository.save(caser);}@GetMapping(value="/getCaser/{id}")public Caser getById(@PathVariable("id") Integer id){ return mCaserRepository.findOne(id);}@PutMapping(value="/saveCaser/{id}/{age}/{name}")public Caser updateCaser(@PathVariable("id")Integer id,@PathVariable("age")Integer age,@PathVariable("name")String name){ Caser one = mCaserRepository.findOne(id); one.setAge(age); one.setName(name); return one;}@DeleteMapping(value="/deleteCaser/{id}")public void deleteCaser(@PathVariable("id")Integer id){ mCaserRepository.delete(id);}
}
但是使用findone获取持久态的实体后,对实体进行更改的时候,并不能同步到数据库,
之后添加了@transactional 注解,同步了…
阅读全文
0 0
- 初学SpringBoot笔记
- 初学SpringBoot笔记
- SpringBoot初学
- SpringBoot初学
- springboot初学 摘记
- SpringBoot初学(一)
- SpringBoot笔记
- SpringBoot笔记
- springBoot笔记
- SpringBoot笔记
- springboot笔记
- springboot 笔记
- SpringBoot笔记
- Springboot 笔记
- 初学笔记
- 初学笔记
- SpringBoot 学习笔记
- SpringBoot 学习笔记 2
- 十大零食加盟,送给你无限商机
- leetcode 87. Scramble String
- Java Calendar 类的时间操作
- 漫威的英雄们,居然还有这种关系!
- 解决Android Studio :Error:Failed to resolve: annotationProcessor
- 初学SpringBoot笔记
- Linux基础之一
- TensorFlow Object Detection API 教程
- Windows7挂载NFS服务
- maven运行时异常:"main" java.lang.UnsupportedClassVersionError解决方法
- NOIP模拟(20171102)T2 最佳序列
- java获取class 路径
- 酷科技 | 智能戒指 ——将科技武装到手指
- JDK 1.8.0_21 bug cpu过高