公众号:踏歌的 Java Daily
读取配置文件中的list
yml格式
test-demo:
test:
- 01
- 02
- 03
properties格式
test-demo.test[0]=01
test-demo.test[1]=02
test-demo.test[2]=03
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;
import java.util.List;
@Data
// 切记prefix的格式为(xx-xx)不能是大驼峰
@ConfigurationProperties(prefix="test-demo")
@Component
public class MaskCipherConfig {
private List<String> test;
}
创作不易请多多支持,更多详情请关注wx工作号:xvguo1127