springboot集成mybatis的注意点
1.修改pom.xml文件
将runtime改为compile
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<scope>compile</scope>
</dependency>
2.mysql配置URL需要添加时区
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/wzx?userUnicode=true&characterEncode=utf-8&serverTimezone=UTC
3.项目入口上面需要添加注解
@MapperScan(“com.example.mybatis.dao”)【dao层的地址】
4.mysql配置供参考
spring.datasource.driver-class-name=com.mysql.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/wzx?userUnicode=true&characterEncode=utf-8&serverTimezone=UTC
spring.datasource.username=root
spring.datasource.password=mysql
spring.datasource.druid.test-on-borrow=true
spring.datasource.druid.test-while-idle=true
mybatis.type-aliases-package=com.example.mybatis.entry
mybatis.mapper-locations=