关于springBoot yml配置文件

  • Post author:
  • Post category:其他


1.application.yml指定配置文件,这里指定application-product.yml配置文件

spring:
  profiles:
    active: product

2.使用指定变量时${host}存在其中application-dev.yml配置文件中,这里active:dev,product不能指定2个配置,会导致项目打包不成功。

  mail:
    host: ${host} # 邮件服务器的SMTP地址
    port: ${port} # 邮件服务器的SMTP端口
    username: ${username} # 发件人
    password: ${password}  # 密码,授权码

3.启动项目必须要dev配置内的变量,可以再idea启动配置里配置VM

(二)mybatis-plus yml内的配置

mybatis-plus:
  configuration:
    map-underscore-to-camel-case: true
#      log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
  type-aliases-package: com.wistron.smart.model
  mapper-locations: classpath:mappers/*.xml
  type-enums-package: com.wistron.smart.enums

1.configLocation 基础配置

map-underscore-to-camel-case: true 开启驼峰命名

默认的java与数据库的要完全对应

数据库表列:user_name

实体类属性:userName

java中一般使用驼峰命名

数据库表列:user_name

实体类属性:userName

log-impl: org.apache.ibatis.logging.stdout.StdOutImpl 开启日志功能

2.type-aliases-package: com.wistron.smart.model

配置后xml中可以直接使用类名,而不用写全路径名resultType 只用写Role

 <select id="findRoleByEmpId" resultType="com.wistorn.linereadiness.model.entity.Role">

3.mapper-locations: classpath:mappers/*.xml

xml扫描路径,这里是resources下的mappers 所有的xml文件。sql操作映射文件

4.type-enums-package: com.wistron.smart.enums

枚举注入,方便类里面直接使用枚举属性。

5.其他配置详解




MyBatis-Plus 配置_原点灬留恋的博客-CSDN博客_mybatis-plus配置



https://blog.csdn.net/qq_40688338/article/details/83380953




版权声明:本文为lisengjiej原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。