我们要提取一下属性:
首先创建一个GirlProperties类
package com.springboot.properties;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* @BelongsProject: springbootideademo
* @BelongsPackage: com.springboot.properties
* @Author: HUANG
* @CreateTime: 2018-11-15 21:46
* @PROJECT_NAME: springbootideademo
*/
@Component
@ConfigurationProperties(prefix = "girl")
public class GirlProperties {
private String cupSize;
private Integer age;
public String getCupSize() {
return cupSize;
}
public void setCupSize(String cupSize) {
this.cupSize = cupSize;
}
public Integer getAge() {
return age;
}
public void setAge(Integer age) {
this.age = age;
}
}
调用方式:
通过属性调用: