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.其他配置详解