The first time to install and use mybatis, problems encountered are as follows:
Question 1: Unkonwn database ‘test’
I created a new test database in my own database, and the corresponding table name, the problem was solved. However, what I want to understand is: how to specify which database and which table to use in the XML configuration file, otherwise, this problem will appear.
Question 2: The server time zone value ‘appears in MySQL й ��� ʱ ‘is unrecognized record
Solution 1: modify the database time zone
set global time_ zone = ‘+8:00’; ## Modify the global time zone of Mysql to Beijing time, that is, the East 8 district where we are
in the database set time_ zone = ‘+8:00’; ## Modify the time zone of the current session
0 flush privileges; # Effective immediately
Solution 2: modify the value of driver and URL.
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Pay attention to this configuration header tag, don't make a mistake -->
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<environments default="bank">
<environment id="bank">
<!-- Using jdbc transaction management -->
<transactionManager type="JDBC" />
<!-- Database connection pooling -->
<dataSource type="POOLED">
<property name="driver" value="com.mysql.cj.jdbc.Driver" />
<property name="url"
value="jdbc:mysql://localhost:3306/test?characterEncoding=utf-8" />
<property name="username" value="root" />
<property name="password" value="123456" />
</dataSource>
</environment>
</environments>
<!-- This place configures the entity class sql mapping file -->
<mappers>
<mapper resource="pufaSpring\otherMybatis\UserMapper.xml"/>
</mappers>
</configuration>