spring 自定义配置属性 嵌套 集合

@ConfigurationProperties("init-data.auth")
public class AuthProperties {
	// 嵌套
	@NestedConfigurationProperty
	private UserDetails admin;
	// 集合
	private Set<UserDetailsProperties> users;
    private List<ResourceDetailsProperties> resources;
    private ClientDetailsProperties[] clients;
    ...
    getter,setter
    ...
}
init-data:
	auth:
		admin:
			username: admin
			password: 1234
		users:
		-	username: user1
			password: 1234
		-	username: user2
			password: 1234
		resources[0]:
			resourcesId: res1
		resources[1]:
			resourcesId: res2
...
		

posted on 2020-03-24 10:34  路过君  阅读(249)  评论(0编辑  收藏  举报

导航