0
点赞
收藏
分享

微信扫一扫

[会写代码的健身爱好者成长史]之@ConfigurationProperties的使用

非凡兔 2022-01-24 阅读 41
@Data
@AllArgsConstructor
@NoArgsConstructor
@Component //必加 放到spring容器中
@ConfigurationProperties(prefix = "user")
public class User {

    private Integer id;
    private String userName;
    private Integer age;
    private String address;
    private String birthday;
}
<!--加这个依赖,@ConfigurationProperties注解和yml文件的配置属性进行绑定会有提示  -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-configuration-processor</artifactId>
        </dependency>

 

 

举报

相关推荐

0 条评论