springboot 各种配置的作用
创始人
2024-02-17 18:15:27

目录

type-aliases-package 配置文件里的作用

配置位置:

配置作用:

map-underscore-to-camel-case: true 配置作用

配置位置

配置作用


type-aliases-package 配置文件里的作用

配置位置:

        .yaml 文件中,不管是代码中,还是配置中心nacos 中都可以配置。

server:port: 8603
spring:datasource:url: jdbc:mysql://localhost:3306/moon?useSSL=falseusername: rootpassword: rootdriver-class-name: com.mysql.jdbc.Driver
mybatis:type-aliases-package: com.zjk.moon.common.entity #实体类所在的包configuration:map-underscore-to-camel-case: true
logging:level:cn.itcast: debugpattern:dateformat: MM-dd HH:mm:ss:SSS

配置作用:

 mybatis:type-aliases-package 的作用就是在Mapper.xml 文件中,会用到resultType 等返回类,我一般会把返回的实体类写成全类名(com.leo.model.UserInfo)这种格式。

使用了type-aliases-package 配置后就可以将全类名写成下面代码块中的类名即可。

map-underscore-to-camel-case: true 配置作用

配置位置

        在.yaml 文件中,包括nacos 的yaml 配置文件也可以。

server:port: 8603
spring:datasource:url: jdbc:mysql://localhost:3306/moon?useSSL=falseusername: rootpassword: rootdriver-class-name: com.mysql.jdbc.Driver
mybatis:type-aliases-package: com.zjk.moon.common.entity #实体类所在的包configuration:map-underscore-to-camel-case: true #设置成驼峰命名法,不设置的话就不是驼峰类型,需要和数据库自动断一致,例如:(不设为true,实体类字段也要设置成tb_book样式)
logging:level:cn.itcast: debugpattern:dateformat: MM-dd HH:mm:ss:SSS

配置作用

#设置成驼峰命名法,不设置的话就不是驼峰类型,需要和数据库自动断一致,例如:(不设为true,实体类字段也要设置成tb_book样式)
设置成true 后:
数据库字段:user_id
实体类字段:userId;

相关内容

热门资讯

7月24日机器人ETF鹏华(1... 7月24日,机器人ETF鹏华(159278)跌3.80%,成交额2.68亿元。当日份额增加1.30亿...
7月24日科创增强ETF银华(... 7月24日,科创增强ETF银华(588690)跌1.26%,成交额199.65万元。当日份额减少40...
7月24日卫星ETF富国(56... 7月24日,卫星ETF富国(563230)跌3.54%,成交额2.00亿元。当日份额增加5400.0...
7月24日恒生科技ETF天弘(... 7月24日,恒生科技ETF天弘(520920)跌1.72%,成交额1.63亿元。当日份额增加1000...
7月24日卫星ETF广发(51... 7月24日,卫星ETF广发(512630)跌3.54%,成交额1.41亿元。当日份额增加4100.0...