SpringBoot yml属性自动注入
本文讲的是如何把一个yml文件中自定义的属性集合映射到一个类上
1.自定义yml 内容
// 以微信的配置为例
weixin:
appid: xxxxxxxxx
appSecret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
apiSecret: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
grantType: authorization_code
2.向spring注册组件类
@Slf4j
@Data
@NoArgsConstructor
@AllArgsConstructor
@Component
@ConfigurationProperties(prefix = "weixin")
public class WeixinProperti