Three MyBatis core configuration files
This article is the third section, and this column records the whole process of MyBatis learning
column directory
Relevant official website instructions -> click to enter
<?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>
<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:///mybatis?serverTimezone=UTC"/>
<property name="username" value="root"/>
<property name="password" value="123456"/>
</dataSource>
</environment>
</environments>
<!-- SQL映射文件位置-->
<mappers>
<mapper resource="org/example/mapper/UserMapper.xml"/>
</mappers>
</configuration>
- The configuration of the environment data source. There can be multiple, that is, multiple database defaults can be configured in the future to determine which database to use
- The management method of transactionManager transaction here defaults to the JDBC method
- dataSource database connection pool The default connection pool of MyBatis is POOLED, which configures the connection information of the data source
<typeAliases>
<package name="org.example.pojo"/>
</typeAliases>
This is how to configure the alias
The meaning of this configuration is: automatically scan the classes under the org.example.pojo package in the future, and use the class name directly when citing it in the future. It is not case-sensitive, and there is no need to write the previous package name.
For detailed configuration information, see the official website at the beginning