| | |
| | | package com.ard.config; |
| | | |
| | | import com.ard.utils.SpringTool; |
| | | import io.minio.MinioClient; |
| | | import lombok.Data; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.beans.factory.config.YamlPropertiesFactoryBean; |
| | | import org.springframework.context.annotation.Bean; |
| | | import org.springframework.core.io.ClassPathResource; |
| | | import org.springframework.core.io.Resource; |
| | | import org.springframework.integration.channel.DefaultHeaderChannelRegistry; |
| | | import org.springframework.integration.channel.PublishSubscribeChannel; |
| | | import org.springframework.stereotype.Component; |
| | | |
| | | import java.io.IOException; |
| | |
| | | private volatile static MinioClient minioClient; |
| | | |
| | | static { |
| | | domainUrl = getYmlNew("minio.endpoint"); |
| | | accessKey = getYmlNew("minio.accessKey"); |
| | | secretKey = getYmlNew("minio.secretKey"); |
| | | domainUrl = SpringTool.getYmlInfo("minio.endpoint"); |
| | | accessKey = SpringTool.getYmlInfo("minio.accessKey"); |
| | | secretKey = SpringTool.getYmlInfo("minio.secretKey"); |
| | | log.info("minio信息:" + domainUrl + "(" + accessKey + "/" + secretKey + ")"); |
| | | } |
| | | |
| | |
| | | return minioClient; |
| | | } |
| | | |
| | | /*yml配置信息获取*/ |
| | | public static String getYmlNew(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(); |
| | | } |
| | | |
| | | @Bean |
| | | public PublishSubscribeChannel errorChannel() { |
| | | return new PublishSubscribeChannel(); |
| | | } |
| | | @Bean |
| | | public DefaultHeaderChannelRegistry integrationHeaderChannelRegistry() { |
| | | return new DefaultHeaderChannelRegistry(); |
| | | } |
| | | } |
| | | |