记录几种异常的处理方法:
1、
Error creating bean with name ‘sqlSessionFactory‘ defined in class path resource [applicationContext-dao.xml]: Error
setting property values; nested exception is org.springframework.beans.PropertyBatchUpdateException; nested
PropertyAccessExceptions (1) are:
PropertyAccessException 1: org.springframework.beans.MethodInvocationException: Property ‘dataSource‘ threw exception; nested
exception is java.lang.NoClassDefFoundError: org/springframework/jdbc/datasource/TransactionAwareDataSourceProxy
在maven工程下 Junit测试 dao 层报错, 原因是缺少spring-jdbc jar包
引入依赖即可
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-jdbc</artifactId>
<version>4.3.7.RELEASE</version>
</dependency>
2、异常报错:An SQLException was provoked by the following failure: java.lang.InterruptedException
原因是没引入mysql-connector-java的jar包,或是mysql-connector-java的版本问题,升级至与mysql版本一致即可。
<dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>8.0.13</version></dependency>
3、springMVC开发web的时候,报错:java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config
原因:未引入jstl包
pom.xml引入jstl,问题解决。
<!-- java.lang.ClassNotFoundException: javax.servlet.jsp.jstl.core.Config --> <dependency> <groupId>javax.servlet</groupId> <artifactId>jstl</artifactId> <version>1.2</version> </dependency>
4、在JDBC使用的时候有时候会出现java.sql.SQLException: The server time zone value ‘???ú±ê×??±??‘ is unrecognized or represents........的错误,具体错误如下:
Loading class `com.mysql.jdbc.Driver‘. This is deprecated. The new driver class is `com.mysql.cj.jdbc.Driver‘. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary.
出现这个的原因是因为 mysql返回的时间总是有问题,比实际时间要早8小时。
解决办法:
jdbc.url = jdbc:mysql://localhost:3306/jdbc01?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8&useSSL=false
在jdbc连接的url后面加上serverTimezone=GMT即可解决问题,如果需要使用gmt+8时区,需要写成GMT%2B8,问题就会解决;
异常记录---Error creating bean with name 'sqlSessionFactory'
原文地址:https://www.cnblogs.com/jsoso/p/11216388.html