异常一(tomcat启动时出现):
SEVERE: StandardWrapper.Throwable org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'accountController': Injection of resource dependencies failed; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'loginDao' defined in class path resource [spring.xml]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property 'sqlSessionFactory' or 'sqlSessionTemplate' are required at org.springframework.context.annotation.CommonAnnotationBeanPostProcessor.postProcessPropertyValues(CommonAnnotationBeanPostProcessor.java:300)
...
花了一天时间检查了n遍配置文件,以及google了n次没有解决,早上一到公司拿到以前的项目,二话不说把以前项目的jar包拷贝过来,重新搭了一个项目,居然没报错。检查昨天项目的jar用的是mybatis-3.2.2.jar+mybatis-spring-1.2.0.jar,而今天用的是mybatis-3.0.5.jar+mybatis-spring-1.0.1.jar,看来最新的不一定是最好的
异常二(连接数据库时出现):
SEVERE: Servlet.service() for servlet [Spring MVC Dispatcher Servlet] in context with path [/testncps] threw exception [Request processing failed; nested exception is org.springframework.jdbc.CannotGetJdbcConnectionException: Could not get JDBC Connection; nested exception is java.sql.SQLException: An attempt by a client to checkout a Connection has timed out.] with root cause
com.mchange.v2.resourcepool.TimeoutException: A client timed out while waiting to acquire a resource from com.mchange.v2.resourcepool.BasicResourcePool@1537fc7 -- timeout at awaitAvailable()
at com.mchange.v2.resourcepool.BasicResourcePool.awaitAvailable(BasicResourcePool.java:1416)
...
jdbc.driverClassName=com.mysql.jdbc.Driver (ps:后面有空格)
jdbc.url=jdbc:mysql://127.0.0.1:3306/1ncpstest
jdbc.username=root
jdbc.password=111111
cpool.checkoutTimeout=5000
cpool.minPoolSize=20
cpool.maxPoolSize=50
cpool.maxIdleTime=7200
cpool.maxIdleTimeExcessConnections=1800
cpool.acquireIncrement=10
检查半天发现是数据库配置中 jdbc.driverClassName=com.mysql.jdbc.Driver ,com.mysql.jdbc.Driver后面出现空格导致的,拷贝东西时记得把多余的空格去掉。
--转自