parent
9b00663116
commit
dd65ce6963
6 changed files with 92 additions and 2 deletions
@ -0,0 +1,17 @@ |
||||
package cc.bnblogs.annotations.controller; |
||||
|
||||
import cc.bnblogs.annotations.entity.Person; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.web.bind.annotation.GetMapping; |
||||
import org.springframework.web.bind.annotation.RestController; |
||||
|
||||
@RestController |
||||
public class PersonController { |
||||
@Autowired |
||||
private Person person; |
||||
|
||||
@GetMapping("/person/") |
||||
public Person getPerson() { |
||||
return person; |
||||
} |
||||
} |
@ -0,0 +1,48 @@ |
||||
package cc.bnblogs.annotations.entity; |
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties; |
||||
import org.springframework.context.annotation.PropertySource; |
||||
import org.springframework.stereotype.Component; |
||||
|
||||
@Component |
||||
@PropertySource(value = {"classpath:static/person.properties"}) |
||||
@ConfigurationProperties(prefix = "person") |
||||
public class Person { |
||||
private String name; |
||||
private String password; |
||||
private String sex; |
||||
private Integer age; |
||||
|
||||
|
||||
public String getName() { |
||||
return name; |
||||
} |
||||
|
||||
public void setName(String name) { |
||||
this.name = name; |
||||
} |
||||
|
||||
public String getPassword() { |
||||
return password; |
||||
} |
||||
|
||||
public void setPassword(String password) { |
||||
this.password = password; |
||||
} |
||||
|
||||
public String getSex() { |
||||
return sex; |
||||
} |
||||
|
||||
public void setSex(String sex) { |
||||
this.sex = sex; |
||||
} |
||||
|
||||
public Integer getAge() { |
||||
return age; |
||||
} |
||||
|
||||
public void setAge(Integer age) { |
||||
this.age = age; |
||||
} |
||||
} |
@ -0,0 +1,4 @@ |
||||
person.name=admin |
||||
person.password=123123 |
||||
person.sex=\u5973 |
||||
person.age=18 |
Loading…
Reference in new issue