my.username=12345
my.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就可以了