org.zodiac.autoconfigure.oss.PlatformMinioAutoConfiguration Maven / Gradle / Ivy
package org.zodiac.autoconfigure.oss;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.zodiac.autoconfigure.oss.condition.ConditionalOnOssEnabled;
import org.zodiac.autoconfigure.security.condition.ConditionalOnSecurityHttpEnabled;
/**
* Minio配置类。
*
*/
@SpringBootConfiguration
@ConditionalOnOssEnabled
//@ConditionalOnWebApplication
@ConditionalOnSecurityHttpEnabled
@AutoConfigureAfter(value = {PlatformOssAutoConfiguration.class})
@ConditionalOnClass(value = {io.minio.MinioClient.class, org.zodiac.oss.config.PlatformOssInfo.class})
@ConditionalOnProperty(value = org.zodiac.oss.constants.OssSystemPropertiesConstants.PLATFORM_OSS_NAME, havingValue = org.zodiac.oss.constants.OssConstants.MINIO)
public class PlatformMinioAutoConfiguration {
private final PlatformOssProperties ossProperties;
private final org.zodiac.oss.rule.OssRule ossRule;
public PlatformMinioAutoConfiguration(PlatformOssProperties ossProperties, org.zodiac.oss.rule.OssRule ossRule) {
this.ossProperties = ossProperties;
this.ossRule = ossRule;
}
@Bean
@ConditionalOnMissingBean
protected io.minio.MinioClient minioClient() {
return io.minio.MinioClient.builder().endpoint(ossProperties.getEndpoint())
.credentials(ossProperties.getAccessKey(), ossProperties.getSecretKey()).build();
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnBean(value = {io.minio.MinioClient.class})
protected org.zodiac.oss.MinioTemplate minioTemplate(io.minio.MinioClient minioClient) {
return new org.zodiac.oss.MinioTemplate(minioClient, ossRule, ossProperties);
}
}