Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘userDao’ defined in URL [jar:file:/C:/MAVEN/maven_repository/maven_repository/com/itheima/ssm_test/ssm_work_dao/1.0-SNAPSHOT/ssm_work_dao-1.0-SNAPSHOT.jar!/com/itheima/ssmwork/dao/UserDao.class]: Invocation of init method failed; nested exception is java.lang.IllegalArgumentException: Property ‘sqlSessionFactory’ or ‘sqlSessionTemplate’ are required
今天做案例的时候发现提示sqlSessionFactroy错误,后发现为applicationContext中 没有配置
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
</bean>
本文详细解析了在Spring框架下配置MyBatis SqlSessionFactory时遇到的常见错误,特别是当applicationContext中未正确配置SqlSessionFactory时的解决方法。通过实例展示了如何在XML配置文件中正确设置SqlSessionFactory,确保其能正确引用数据源(dataSource),从而避免初始化失败或IllegalArgumentException异常。
1564

被折叠的 条评论
为什么被折叠?



