创建Mybatis工程时的一些小技巧

1.快速创建多个包套文件

2.快速创建多个包

java下可以直接创建package包

resource下不能直接创建包,所以要用分隔符/来分割

注意其命名规范和创建方式

与《快速创建多个包套文件》区分开来

3.快速生成前半部分代码

//打一半代码
sqlSessionFactory.openSession();
//alt+enter
SqlSession sqlSession = sqlSessionFactory.openSession();

 

解决问题

问题1

### Error querying database.  Cause: java.sql.SQLException: No suitable driver found for jdbc:mysql//localhost:3306/...

这里报错

url 格式错误,mysql后面要加

问题2

org.apache.ibatis.binding.BindingException: Type interface com.SZX.Mapper.ParameterMapper is not known to the MapperRegistry.

问题3

### Error building SqlSession.
### The error may exist in com/SZX/Mapper/ParameterMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: org.apache.ibatis.builder.BuilderException: Error parsing Mapper XML. The XML location is 'com/SZX/Mapper/ParameterMapper.xml'. Cause: org.apache.ibatis.builder.BuilderException: Wrong namespace. Expected 'com.SZX.Mapper.ParameterMapper' but found 'com.SZX.Mapper.ParameterMapper1'.

posted @ 2022-10-16 22:12  莫扎特03  阅读(18)  评论(0编辑  收藏  举报