推荐先阅读
:Spring全家桶
可对比:Spring整合MyBatis
基于SpringBoot实现SSM
- SpringBoot整合Spring(不存在)
- SpringBoot整合SpringMVC(不存在)
- SpringBoot整合MyBatis(主要)
<dependency> <groupId>com.alibaba</groupId> <artifactId>druid</artifactId> <version>1.1.16</version> </dependency>
|
设置数据源参数
spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/ssm_db?serverTimezone=UTC username: root password: root type: com.alibaba.druid.pool.DruidDataSource
|
SpringBoot
版本低于2.4.3(不含),Mysql驱动版本大于8.0时,需要在url连接串中配置时区 jdbc:mysql://localhost:3306/ssm_db?serverTimezone=UTC
,或在MySQL数据库端配置时区解决此问题
定义数据层接口与映射配置 @Mapper
@Mapper public interface BookDao { @Select("select * from tbl_book where id = #{id}") public Book getById(Integer id); }
|