springboot绑定属性

来源:互联网 发布:数据共享的方式 编辑:程序博客网 时间:2024/06/17 21:37
my.username=12345my.name=kkk
package demo1.bean;import org.springframework.boot.context.properties.ConfigurationProperties;import org.springframework.boot.context.properties.ConfigurationPropertiesBinding;import org.springframework.stereotype.Component;/** * Created by LM on 2017/8/6. */@Component@ConfigurationProperties("my")public class SystemProperties {    private String username;    private String name;    public String getUsername() {        return username;    }    public void setUsername(String username) {        this.username = username;    }    public String getName() {        return name;    }    public void setName(String name) {        this.name = name;    }}注入直接get就可以了
原创粉丝点击