View Javadoc
1   package cn.home1.oss.environment.configlint;
2   
3   import org.slf4j.Logger;
4   import org.slf4j.LoggerFactory;
5   import org.springframework.boot.env.PropertySourcesLoader;
6   import org.springframework.core.io.FileSystemResource;
7   
8   import java.io.IOException;
9   
10  /**
11   * Created by melody on 2016/11/9.
12   */
13  public class YmlValidator implements FileValidator {
14  
15    private static final Logger log = LoggerFactory.getLogger(PropertyValidator.class);
16  
17    public void validate(final String path) {
18      // 运行时异常直接抛出,不处理
19      try {
20        final PropertySourcesLoader psLoader = new PropertySourcesLoader();
21        final FileSystemResource res = new FileSystemResource(path);
22        psLoader.load(res);
23      } catch (final IOException ex) {
24        log.warn("error loading yml file {}", path, ex);
25      }
26    }
27  }