|
在配置文件内容
- school:
- name: 社会大学
- address: 长沙
- postnumber: 416716
复制代码 新建映射类
- import org.springframework.boot.context.properties.ConfigurationProperties;
- import org.springframework.stereotype.Component;
- @Component
- @ConfigurationProperties(prefix = "school")
- public class SchoolInfo {
- private String name;
- private String address;
- private Integer postnumber;
- public String getName() {
- return name;
- }
- public void setName(String name) {
- this.name = name;
- }
- public String getAddress() {
- return address;
- }
- public void setAddress(String address) {
- this.address = address;
- }
- public Integer getPostnumber() {
- return postnumber;
- }
- public void setPostnumber(Integer postnumber) {
- this.postnumber = postnumber;
- }
- @Override
- public String toString() {
- return "SchoolInfo{" +
- "name='" + name + '\'' +
- ", address='" + address + '\'' +
- ", postnumber=" + postnumber +
- '}';
- }
- }
复制代码 提示: Spring Boot Configuration Annotation Processor not configured
不处理也没有关系,如果要处理可以添加maven依赖
- <dependency>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-configuration-processor</artifactId>
- </dependency>
复制代码
|
|