MyBatis-Plus——超详细讲解配置文件

MyBatis-Plus——超详细讲解配置文件,第1张

MyBatis-Plus——超详细讲解配置文件



哈喽!大家好,我是【一心同学】,一位上进心十足的【Java领域博主】!

✨【一心同学】的写作风格:喜欢用【通俗易懂】的文笔去讲解每一个知识点,而不喜欢用【高大上】的官方陈述。

✨【一心同学】博客的领域是【面向后端技术】的学习,未来会持续更新更多的【后端技术】以及【学习心得】。

✨如果有对【后端技术】感兴趣的【小可爱】,欢迎关注【一心同学】

❤️❤️❤️感谢各位大可爱小可爱!❤️❤️❤️ 


目录

前言

1、mapperLocations

2、typeAliasesPackage

3、typeHandlersPackage

4、typeEnumsPackage

5、checkConfigLocation

6、executorType

7、configurationProperties

8、configuration

8.1  mapUnderscoreToCamelCase

8.2  defaultEnumTypeHandler

8.3  aggressiveLazyLoading

8.4  autoMappingBehavior

8.5  autoMappingUnknownColumnBehavior

8.6  localCacheScope

8.7  cacheEnabled

8.8  callSettersOnNulls

8.9  configurationFactory

9、MyBatis的配置属性

10、globalConfig

10.1  banner

10.2  enableSqlRunner

10.3  superMapperClass

10.4  dbConfig

10.4.1  idType

10.4.2  tablePrefix

10.4.3  schema

10.4.4  columnFormat

10.4.5  propertyFormat

10.4.6  tableUnderline

10.4.6  capitalMode

10.4.7  logicDeleteField

10.4.8  logicDeletevalue

10.4.9  logicNotDeletevalue

10.4.10  insertStrategy

10.4.11  updateStrategy

10.4.12  selectStrategy

11、 配置小结

小结


前言

在我们的【MyBatis-Plus】中有许多【配置】,也就是当我们需要用到的时候,会在配置文件中进行编写的属性,本篇博客将会讲解这些配置的【作用】,以及简单【使用】。

1、mapperLocations

类型:String[]默认值:["classpath*:/mapper*.xml"]

介绍:扫描MyBatis Mapper 所对应的 XML 文件位置,如果在 Mapper 中有自定义方法(XML 中有自定义实现),需要进行该配置,告诉 Mapper 所对应的 XML 文件位置,Maven 多模块项目的扫描路径需以 classpath*: 开头 (即加载多个 jar 包下的 XML 文件)。

mybatis-plus.mapper-locations=classpath*:**/mapper/xmlmapper/xml/*.xml
mybatis-plus.type-aliases-package=com.caochenlei.mpdemo.pojo
mybatis-plus.type-handlers-package=com.caochenlei.mpdemo.type
mybatis-plus.type-enums-package=com.caochenlei.mpdemo.enum
mybatis-plus.check-config-location=false
mybatis-plus.executor-type=simple

#mybatis-plus.configuration
mybatis-plus.configuration.map-underscore-to-camel-case=true
mybatis-plus.configuration.default-enum-type-handler=org.apache.ibatis.type.EnumTypeHandler
mybatis-plus.configuration.aggressive-lazy-loading=true
mybatis-plus.configuration.lazy-loading-enabled=true
mybatis-plus.configuration.auto-mapping-behavior=partial
mybatis-plus.configuration.auto-mapping-unknown-column-behavior=none
mybatis-plus.configuration.local-cache-scope=session
mybatis-plus.configuration.cache-enabled=true
mybatis-plus.configuration.call-setters-on-nulls=false
mybatis-plus.configuration.configuration-factory=
mybatis-plus.configuration.log-impl=org.apache.ibatis.logging.stdout.StdOutImpl

#mybatis-plus.global-config
mybatis-plus.global-config.banner=true
mybatis-plus.global-config.enable-sql-runner=false
mybatis-plus.global-config.super-mapper-class=com.baomidou.mybatisplus.core.mapper.Mapper

#mybatis-plus.global-config.db-config
mybatis-plus.global-config.db-config.id-type=assign_id
mybatis-plus.global-config.db-config.table-prefix=tbl_
mybatis-plus.global-config.db-config.schema=
mybatis-plus.global-config.db-config.column-format=
mybatis-plus.global-config.db-config.property-format=
mybatis-plus.global-config.db-config.table-underline=true
mybatis-plus.global-config.db-config.capital-mode=false
mybatis-plus.global-config.db-config.logic-delete-field=
mybatis-plus.global-config.db-config.logic-delete-value=1
mybatis-plus.global-config.db-config.logic-not-delete-value=0
mybatis-plus.global-config.db-config.insert-strategy=not_null
mybatis-plus.global-config.db-config.update-strategy=not_null
mybatis-plus.global-config.db-config.select-strategy=not_null


小结

以上的【MyBatis-Plus配置详解】是一心同学是在网上阅读了不少【文章】,同时也有参考了几位【牛人】的讲解,最后【整理】出来的,大家也看到,这配置是非常的多,我们只需要大概知道其配置有什么功能,然后在开发过程中直接【应用】即可。

如果这篇【文章】有帮助到你,希望可以给【一心同学】点个赞,创作不易,相比官方的陈述,我更喜欢用【通俗易懂】的文笔去讲解每一个知识点,如果有对【后端技术】感兴趣的小可爱,也欢迎关注❤️❤️❤️ 【一心同学】❤️❤️❤️,我将会给你带来巨大的【收获与惊喜】!

欢迎分享,转载请注明来源:内存溢出

原文地址: https://www.outofmemory.cn/zaji/5706728.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存