美文网首页
springboot(三)配置

springboot(三)配置

作者: 时代劫匪 | 来源:发表于2020-06-16 23:21 被阅读0次

yaml可以直接给实体类赋值
yaml约定位置:(优先级1最高)

  1. file:/config/
  2. file:/
  3. classpath:/config/
  4. classpath:/

yaml多文件块

server:
  port: 8081

spring:
  profiles:
    active: test

---
server:
  port: 8082
spring:
  profiles: dev

---
server:
  port: 8083
spring:
  profiles: test

自动装配

1.SpringBoot启动会加载大量自动装配配置类
2.我们看我们需要的功能有没有在SpringBoot默认写好的自动配置类当中
3.我们再来看这个自动配置类中到底配置了那些逐渐;(只要我们要用的组件存在在其中,我们就不需要再手动配置了)
4.给容器中自动配置类添加组件的时候,会从properties类中获取某些属性。我们只需要再配置文件中指定这些属性的值即可
xxxAutoConfigurartion:自动配置类;给容器中添加组件
xxxxProperties:封装配置文件中0相关属性

相关文章

网友评论

      本文标题:springboot(三)配置

      本文链接:https://www.haomeiwen.com/subject/glbytktx.html