MyBatis配置时的问题与解决办法

1.别名类型type错误,找不到类。
报错信息:(核心)

Caused by: org.apache.ibatis.builder.BuilderException: 
Error parsing SQL Mapper Configuration. Cause: 			
org.apache.ibatis.builder.BuilderException: Error registering typeAlias for 'MessageResult'. 
Cause: java.lang.ClassNotFoundException: Cannot find class: Message

解决办法:
configuration.xml 核心配置文件中
在这里插入图片描述
message.xml mybatis的SQL语句配置文件(在配置文件夹新建sql文件夹,里面存放对各个表操作的sql配置文件,例message表名,则对应的message.xml)

在这里插入图片描述
2.数据库URL问题(编码、时区)

java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' 
is unrecognized or represents more than one time zone. 
You must configure either the server or JDBC driver 
(via the serverTimezone configuration property) to 
use a more specifc time zone value if you want to utilize time zone support.

时区:url地址加上 : ?serverTimezone=GMT%2B8 东八区
编码方式支持中文:&useUnicode=true&characterEncoding=UTF8
正常格式(xml里面:&代表转义 &):jdbc:mysql://IP/数据库名?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF8

jdbc:mysql://localhost/testliu?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=UTF8

猜你喜欢

转载自blog.csdn.net/WhenTheWindBlows/article/details/87876085
今日推荐