| | |
| | | package com.ard.utils; |
| | | |
| | | import org.springframework.beans.BeansException; |
| | | import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; |
| | | import org.springframework.context.ApplicationContext; |
| | | import org.springframework.context.ApplicationContextAware; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.core.io.Resource; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.nio.ByteBuffer; |
| | | import java.util.Properties; |
| | | |
| | | /** |
| | | * @Description: |
| | |
| | | return getApplicationContext().getBean(name); |
| | | } |
| | | |
| | | /*yml配置信息获取*/ |
| | | public static String getYmlInfo(String key) { |
| | | Resource resource = new ClassPathResource("application.yml"); |
| | | Properties properties = null; |
| | | try { |
| | | YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean(); |
| | | yamlFactory.setResources(resource); |
| | | properties = yamlFactory.getObject(); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return null; |
| | | } |
| | | return properties.get(key).toString(); |
| | | } |
| | | } |