文章目录
任务:修改StudentInfo项目输出学生信息
1.创建学生实体类
package net.lbj.lesson.bean;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
/**
* 学生实体类
* 20210428
*/
@Component
@ConfigurationProperties(prefix = "student")
public class Student {
private String id;
private String name;
private String gender;
private int age;
private String major;
private String telephone;
private String email;
private String hobby;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getGender() {
return gender;
}
public void setGender(String gender) {
this.gender = gender;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getMajor() {
return major;
}
public void setMajor(String major) {
this.major = major;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getHobby() {
return hobby;
}
public void setHobby(String hobby) {
this.hobby = hobby;
}
@Override
public String toString() {
return "Student{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", gender='" + gender + '\'' +
", age=" + age +
", major='" + major + '\'' +
", telephone='" + telephone + '\'' +
", email='" + email + '\'' +
", hobby='" + hobby + '\'' +
'}';
}
}
2.配置student对象属性
将application.properties更名为application.yaml
#配置student对象
student:
id: 19242036
name: 张侨侨
gender: 女
age: 20
major: 软件技术
telephone: 15228342231
email: math007@qq.cpm
hobby: 音乐,旅游,编程