SpringBoot ConfigurationProperties使用详解源代码

occurrence_37033 9 0 zip 2023-01-30 10:01:19

1.1简述在Spring Boot中注解ConfigurationProperties有三种使用场景而通常情况下我们使用的最多的只是其中的一种场景.本篇文章带大家了解一下三种场景的使用情况.1.2场景一使用ConfigurationProperties和Component注解到bean定义类上这里Component代指同一类实例化Bean的注解.1.3场景二使用ConfigurationProperties和Bean注解在配置类的Bean定义方法上.以数据源配置为例使用ConfigurationProperties注解到普通类然后再通过EnableConfigurationPropertiesz注解到启动类中定义为Bean.这里User对象并没有使用Component相关注解.EnableConfigurationProperties关于EnableConfigurationProperties注解的使用EnableConfigurationProperties的作用是把springboot配置文件中的值与我们的xxxPr

用户评论
请输入评论内容
评分:
暂无评论