Mybatis 持久层框架

gradle中添加mybatis依赖以及数据库驱动:

    

dependencies {
//导入mybatis依赖
implementation('org.mybatis:mybatis:3.5.5')
//导入mysql驱动
implementation('mysql:mysql-connector-java:8.0.20')
}



添加mybatis总配置:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<settings>
<setting name="mapUnderscoreToCamelCase" value="true"/>
</settings>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="url"
value="jdbc:mysql://127.0.0.1:3306/course?useUnicode=true&amp;characterEncoding=utf-8&amp;useSSL=false&amp;serverTimezone=UTC"/>
<property name="username" value="root"/>
<property name="password" value="123321"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="org/mybatis/example/BlogMapper.xml"/>
</mappers>
</configuration>
 
上一篇:【六级单词】2022.1.26


下一篇:【luogu P1989】无向图三元环计数(图论)(分类讨论)