问题?org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction
整合大三大框架的时候,单独测试没问题,在请求action的时候,会出现以下问题:
org.springframework.transaction.CannotCreateTransactionException: Could not open JDBC Connection for transaction; nested exception is java.sql.SQLException: Io 异常: The Network Adapter could not establish the connection
at org.springframework.jdbc.datasource.DataSourceTransactionManager.doBegin(DataSourceTransactionManager.java:238)
at org.springframework.transaction.support.AbstractPlatformTransactionManager.getTransaction(AbstractPlatformTransactionManager.java:374)
at org.springframework.transaction.interceptor.TransactionAspectSupport.createTransactionIfNecessary(TransactionAspectSupport.java:263)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:101)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
at $Proxy4.find(Unknown Source)
解决:
在hibernate.cfg.xml中加入
<property name="connection.driver_class">
com.mysql.jdbc.Driver
</property>
这是因为没有找到驱动的原因。