idea在新建springboot项目时可以勾选mybatis的依赖,然后pom文件里面就会导入mybatis的依赖。
但如果要使用通用mapper的话,就得导入通用mapper的包
<!-- https://mvnrepository.com/artifact/tk.mybatis/mapper-spring-boot-starter -->
<dependency>
<groupId>tk.mybatis</groupId>
<artifactId>mapper-spring-boot-starter</artifactId>
<version>2.1.5</version>
</dependency>
版本可以自己选择
导入这个包之后,要做的就是配置文件的配置
#起别名。可省略写mybatis的xml中的resultType的全路径(实体在的位置)
mybatis.type-aliases-package=com.bosssoft.exam.entity
mybatis.configuration.map-underscore-to-camel-case= true
# mybatis接口文件位置(这里的mapper是resource目录下的一个文件)
mybatis.mapper-locations=classpath:mapper/*.xml
这样配置就可以了,网上很多通用mapper的教程,都很全面