提示为语法错误:
Cause: java.sql.SQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near
<select id="getName" resultType="com.mybatisTest.entry.User">
select * from user.class where name = '张三'
</select>
原因:
在配置时没有指定数据库编码
修改之前:
<dataSource type="POOLED">
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3308/user"/>
修改之后:
<dataSource type="POOLED">
<property name="driver" value="com.mysql.cj.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3308/user?useUnicode=true&characterEncoding=UTF-8"/>