一、在springboot配置druid连接池时发现的错误,错误信息如下:
Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException:
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.
从上面的信息可以看出是错误原因是是time-zone 的问题。
原来的配置信息:
spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf-8
加上 &serverTimezone=GMT%2B8 j即可。即:
spring.datasource.url=jdbc:mysql://localhost:3306/springboot?useUnicode=true&characterEncoding=utf-8&serverTimezone=GMT%2B8
二、dao层映射mapper文件时,出现找不到方法:错误提示如下:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
com.example.demo.dao.PersonDao.selectAll
导致如下错误原因有:
1、映射的dao类名不一致,或者方法名不一致。
2、 对应的sql映射文件mapper要跟dao层类名一致,或者类名首字母小写,否则dao层类找不到对应的执行sql。
3、除此之外,如果mapper文件不是再resource目录下,则需要在pom文件下指明资源文件的位置。
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>