未来可期,小哥需努力!
spring boot整合mybatis
#修改Tomcat的端口 server: port: 8081 #数据库信息 spring: datasource: url: jdbc:mysql://localhost:3306/mybatis_study?useUnicode=true&characterEncoding=utf-8&useSSL=true&serverTimezone=UTC driver-class-name: com.mysql.cj.jdbc.Driver username: root password: xxxxxx #mybatis mybatis: mapper-locations: classpath:mapping/*Mapping.xml type-aliases-package: com.springboot_mybatis.domain
public class User { private Integer id; private String username; private Date birthday; private String sex; private String address; get and set 方法.....
public interface UserDao { List<User> findAll(); User findById(); void addUser(); }
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.springboot_mybatis.dao.UserDao"> <select id="findAll" resultType="com.springboot_mybatis.domain.User"> select * from user </select> </mapper>
@Service public class UserServiceImpl implements UserService { @Autowired private UserDao userDao; // 服务调用dao层,查询全部 @Override public List<User> findAllUser() { return userDao.findAll(); } }
@Controller public class UserController { @Autowired private UserService userService; @ResponseBody @GetMapping(value = "/users") public List<User> findAllUser(){ List<User> list = userService.findAllUser(); return list; } }
@MapperScan("com.springboot_mybatis.dao") @SpringBootApplication public class DemoApplication { public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); } }
本网页所有视频内容由 imoviebox边看边下-网页视频下载, iurlBox网页地址收藏管理器 下载并得到。
ImovieBox网页视频下载器 下载地址: ImovieBox网页视频下载器-最新版本下载
本文章由: imapbox邮箱云存储,邮箱网盘,ImageBox 图片批量下载器,网页图片批量下载专家,网页图片批量下载器,获取到文章图片,imoviebox网页视频批量下载器,下载视频内容,为您提供.
阅读和此文章类似的: 全球云计算