mirror of
https://github.com/JeffLi1993/springboot-learning-example.git
synced 2026-03-14 14:13:52 +08:00
属性
This commit is contained in:
@@ -0,0 +1,76 @@
|
||||
package org.spring.springboot.domain;
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 用户
|
||||
*
|
||||
* Created by bysocket on 18/04/2017.
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "user")
|
||||
public class User {
|
||||
|
||||
/**
|
||||
* 用户 ID
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 年龄
|
||||
*/
|
||||
private int age;
|
||||
|
||||
/**
|
||||
* 用户名称
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
/**
|
||||
* 用户 UUID
|
||||
*/
|
||||
private String uuid;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
|
||||
public String getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(String uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "User{" +
|
||||
"id=" + id +
|
||||
", age=" + age +
|
||||
", desc=" + desc +
|
||||
", uuid='" + uuid + '\'' +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import org.springframework.stereotype.Component;
|
||||
* Created by bysocket on 17/04/2017.
|
||||
*/
|
||||
@Component
|
||||
public class HomeProperties {
|
||||
public class HomeProperties1 {
|
||||
|
||||
/**
|
||||
* 省份
|
||||
@@ -0,0 +1,54 @@
|
||||
package org.spring.springboot.property;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 家乡属性
|
||||
*
|
||||
* Created by bysocket on 17/04/2017.
|
||||
*/
|
||||
@Component
|
||||
@ConfigurationProperties(prefix = "home")
|
||||
public class HomeProperties2 {
|
||||
|
||||
/**
|
||||
* 省份
|
||||
*/
|
||||
private String province;
|
||||
|
||||
/**
|
||||
* 城市
|
||||
*/
|
||||
private String city;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String desc;
|
||||
|
||||
public String getProvince() {
|
||||
return province;
|
||||
}
|
||||
|
||||
public void setProvince(String province) {
|
||||
this.province = province;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return city;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public String getDesc() {
|
||||
return desc;
|
||||
}
|
||||
|
||||
public void setDesc(String desc) {
|
||||
this.desc = desc;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user