yaml可以直接给实体类赋值
yaml约定位置:(优先级1最高)
- file:/config/
- file:/
- classpath:/config/
- 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相关属性
网友评论