MyBatis与Spring整合,其主要任务是将MyBatis的SqlSessionFactory交由Spring容器来管理。
Mybatis.xml
日志文件
Application.xml
异常
org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'mySqlsessionFactory' defined in class path resource [applicationContext.xml]: Initialization of bean failed; nested exception is org.springframework.beans.ConversionNotSupportedException:
Failed to convert property value of type 'java.lang.String' to required type 'javax.sql.DataSource' for property 'dataSource'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'java.lang.String' to required type 'javax.sql.DataSource' for property 'dataSource': no matching editors or conversion strategy found
优化,当出现多个dao接口时,会造成代码臃肿
Tx事务
Caused by: org.springframework.beans.factory.BeanCreationException:
Error creating bean with name 'txAdvice':
Cannot resolve reference to bean 'transactionManager' while setting bean property 'transactionManager';
nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException:
No bean named 'transactionManager' available