spring boot怎么写java web和接口
发表于:2024-10-27 作者:千家信息网编辑
千家信息网最后更新 2024年10月27日,本篇内容主要讲解"spring boot怎么写java web和接口",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"spring boot怎么写java w
千家信息网最后更新 2024年10月27日spring boot怎么写java web和接口
本篇内容主要讲解"spring boot怎么写java web和接口",感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习"spring boot怎么写java web和接口"吧!
流程:
Springboot开发过程
还有一个是mybatis
的依赖
测试接口
@RestControllerpublic class Hello { @RequestMapping("/hello") public String hello(){ return "helloworld"; }}
***.yml文件配置
spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/student?useUnicode=true&useSSL=false&characterEncoding=utf8&serverTimezone=Asia/Shanghai username: root password: 123456mybatis: mapper-locations: classpath:mapper/*.xml
数据库字段:
pojo
@Datapublic class User { private int id ; private String name; private int age; private String email; *****
剩下的就是get
和set
方法自行完成
mapper
@Mapperpublic interface UserMapper { ListfindAll();}
如果是springboot
,在启动类中使用@MapperScan
("mapper接口所在包全名")即可,不用一个一个的在Mapper接口中加@Mapper注解。@Mapper注解是识别他为mybatis的mapper接口,会自动的把 加@Mapper 注解的接口生成动态代理类。
让springboot
认识你的mapper层,也可以在启动类上面加MapperScan
("mapper层所在包的全名")
mapper.xml
controller
@RestControllerpublic class UserController { @Autowired //把userService实例化 private UserService userService; @RequestMapping("/user") public ListgetUser(){ return userService.findAll(); }}
注意一定要把userService
注入到容器中
数据成功拿到
到此,相信大家对"spring boot怎么写java web和接口"有了更深的了解,不妨来实际操作一番吧!这里是网站,更多相关内容可以进入相关频道进行查询,关注我们,继续学习!
接口
注解
全名
内容
所在
数据
方法
学习
实用
更深
成功
不用
兴趣
动态
字段
实例
实用性
实际
容器
就是
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
国际专利数据库使用方法
怎样删除qq服务器聊天记录
华为手机无法连接服务器怎么开启
服务器搭建游戏的危害
网络安全技术课程论文
网络安全指令检测报告心得
漳平专业软件开发多少钱
手游服务器被禁用怎么解除
江苏智铭网络技术有限公司
联想服务器 ts530
手机安卓软件开发视频网站
2021工信网络安全条例
开斯利数据库
s7服务器
qt怎么把文件存到数据库
网站服务器怎么备份
embase数据库如何输出文献
我的世界服务器开局送合金套
软件设计数据库设计要求
崂山区定制软件开发公司
西电成都网络安全研究院介绍
服务器搭建游戏的危害
中讯邮电设计软件开发中心
能够进入宇宙数据库的
在数据库检索得到的文章都是可以
七彩管理通服务器
软件开发各个阶段内容图
pve服务器排行
编程代码和软件开发好学吗
酒店安全隐患数据库