边学边做--学习笔记(三)
作者:互联网
1.spring-boot集成mybatis
引入依赖
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-jdbc</artifactId>
</dependency>
在properties里面填写好spring.datasource.username,
spring.datasource.password spring.datasource.driver-class-name三个重要信息
2.抛弃视频教程里面的h2数据库转头使用mysql数据库
我是真的难受,h2数据库用不来,还是换成了比较熟悉的mysql数据库
引入mysql的依赖
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
</dependency>
最新的依赖要用如下驱动类配置否则就会报错
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
运行时报java.sql.SQLException: The server time zone value ‘�й���ʱ��’ is unrecognized or represents more than one time zone.则需要在spring.datasource.url=jdbc:mysql://localhost:3306/community中连接上参数serverTimezone=UTC (MySQL jdbc 6.0 版本以上必须配置此参数)
标签:jdbc,spring,boot,笔记,学习,datasource,mysql,mybatis,边学边 来源: https://blog.csdn.net/qq_42265043/article/details/100662137