嘻哈飞车族|SpringBoot:数据库访问之Mybatis( 二 )
5 修改属性配置文件
#jdbc信息spring.datasource.username=rootspring.datasource.password=123456spring.datasource.driver-class-name=com.mysql.jdbc.Driverspring.datasource.url=jdbc:mysql://localhost:3306/test?characterEncoding=utf-8}}7 创建访问的controller
@RestControllerpublic class MybatisDemoController {@Autowiredprivate DemoService demoService;@RequestMapping(value="http://kandian.youth.cn/save", method=RequestMethod.POST)public String save(@RequestParam("name") String name, @RequestParam("telphone") String telphone){DemoEntity entity = new DemoEntity();entity.setName(name);entity.setTelphone(telphone);int result = demoService.save(entity);return String.valueOf(result);}@RequestMapping(value="http://kandian.youth.cn/get", method=RequestMethod.GET)public String getById(@RequestParam("id") Integer id){DemoEntity entity = demoService.selectById(id);return entity.toString();}@RequestMapping(value="http://kandian.youth.cn/delete", method=RequestMethod.POST)public String delete(@RequestParam("id") Integer id){int result = demoService.deleteById(id);return String.valueOf(result);}@RequestMapping(value="http://kandian.youth.cn/update", method=RequestMethod.POST)public String update(DemoEntity entity){demoService.updateDemoEntity(entity);return "success";}}启动服务后 , 即可访问测试 。
推荐阅读
- 「李小璐」李小璐带甜馨现身嘻哈风乐器房,两年前她在此被质疑表白PG1
- 嘻哈段子|我堂哥当年喜欢邻村一个女孩子,天天去她家晃悠,蹭饭吃,幽默笑话:
- 嘻哈飞车族|还有一周:沃尔玛能否成为TikTok最后的买家?
- 嘻哈段子|青椒炒黄瓜,半斤大米肉丝汤?,幽默笑话:床前明月光
- 几品飞车|都2020年了,苹果4G iPhone仍很畅销,说明了什么?
- 一味宠爱|Springboot整合K8s读取ConfigMap刷新配置
- 嘻哈飞车族|要警惕!美国这次来真的:绕开5G研发6G,真不是噱头
- 嘻哈小甜甜|DNF:希洛克困难三次改动!花瓣材料大幅增加,融合SS概率提升
- 中国新说唱|没有火药味的《中国新说唱》太不嘻哈了,没有beef只有Auto-Tune
- 嘻哈小甜甜|KPL首周赛程曝光:3场比赛不容错过,AG复仇Ts,新e星首战AG!
