配置
- springBoot工程
- 配置 MapperScan 注解
@SpringBootApplication
@MapperScan("mapper文件位置")
public class Application {
public static void main(String[] args) {
SpringApplication.run(QuickStartApplication.class, args);
}
}
一般来说,简单工程通过以上配置就可以正常使用MyBatis-Plus了
时 MyBatis-Plus 提供了大量的个性化配置来满足不同复杂度的工程,可以按照项目需求使用
基本配置
configLocation
- 类型 string
- 默认值 null
MyBatis 配置文件位置,如果您有单独的 MyBatis 配置,请将其路径配置到 configLocation 中
mybatis-plus:
mapper-locations: classpath*:mybatis/*.xml
typeAliasesPackage
- 类型 string
- 默认值 null
MyBaits 别名包扫描路径,通过该属性可以给包中的类注册别名,注册后在 Mapper 对应的 XML 文件中可以直接使用类名,而不用使用全限定的类名(即 XML 中调用的时候不用包含包名)。
mybatis-plus:
type-aliases-package: com.baomidou.mybatisplus.samples.quickstart.entity
typeAliasesSuperType
- 类型 string
- 默认值 null
该配置请和 typeAliasesPackage 一起使用,如果配置了该属性,则仅仅会扫描路径下以该类作为父类的域对象 。
mybatis-plus:
type-aliases-package: com.baomidou.mybatisplus.samples.quickstart.entity
type-aliases-super-type: java.lang.Object
typeHandlersPackage
- 类型 string
- 默认值 null
TypeHandler 扫描路径,如果配置了该属性,SqlSessionFactoryBean 会把该包下面的类注册为对应的 TypeHandler。
mybatis-plus:
本文档详细介绍了MyBatis-Plus的配置,包括基本配置、进阶配置和DB策略配置。基本配置中涉及了configLocation、typeAliasesPackage等属性,进阶配置包括mapUnderscoreToCamelCase、executorType等,DB策略配置如capitalMode、dbType等。这些配置可以帮助用户根据项目需求调整MyBatis-Plus的行为。
最低0.47元/天 解锁文章


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



