app.user.name=John Doe app.user.age=30 app.user.address.city=New York app.user.address.country=USA
import org.springframework.boot.context.properties.ConfigurationProperties; import org.springframework.context.annotation.Configuration; @Configuration @ConfigurationProperties(prefix = "app") public class AppConfig { private User user; public User getUser() { return user; } public void setUser(User user) { this.user = user; } public static class User { private String name; private int age; private Address address; // getters and setters public static class Address { private String city; private String country; // getters and setters } } }
标签:层级,springboot,app,private,User,String,user,public,属性 From: https://www.cnblogs.com/privateLogs/p/18320011