读取yml文件 @param fileName 文件名称 例如application.yml @return
(String fileName)
| 44 | * @return |
| 45 | */ |
| 46 | public static Properties getYml(String fileName){ |
| 47 | Resource resource = new ClassPathResource(fileName); |
| 48 | Properties properties = null; |
| 49 | try { |
| 50 | YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean(); |
| 51 | yamlFactory.setResources(resource); |
| 52 | properties = yamlFactory.getObject(); |
| 53 | } catch (Exception e) { |
| 54 | if (logger.isErrorEnabled()) { |
| 55 | logger.error("读取yml文件错误 "+fileName,e); |
| 56 | } |
| 57 | return null; |
| 58 | } |
| 59 | return properties; |
| 60 | } |
| 61 | } |
no outgoing calls