欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

Mybatis PersistenceException异常:Error building SqlSession The error may exist in SQL Mapper Configur

程序员文章站 2022-06-22 20:26:01
初学mybatis出现了这个异常:org.apache.ibatis.exceptions.PersistenceException: ### Error building SqlSession.### The error may exist in SQL Mapper Configuration### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: o...

初学mybatis出现了这个异常:

org.apache.ibatis.exceptions.PersistenceException: 
### Error building SqlSession.
### The error may exist in SQL Mapper Configuration
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.datasource.DataSourceException: Unknown DataSource property: driverClassName

通过调试发现错误出现在第三行代码

InputStream in = Resources.getResourceAsStream("SqlMapConfig.xml");
SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
SqlSessionFactory factory = builder.build(in);

确定问题出在 SqlMapConfig.xml配置文件中

仔细检查自己的配置文件

<transactionManager type=""></transactionManager>

发现 tpye属性忘了赋值

<transactionManager type="JDBC"></transactionManager>

重新赋值之后成功链接上了数据库

本文地址:https://blog.csdn.net/weixin_45718916/article/details/107665683