com.zopen.ato.autoconfigure.WechatWorkAutoConfiguration Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of zopen-ato-starter Show documentation
Show all versions of zopen-ato-starter Show documentation
Alibaba Tencent And Others For Spring Boot.
package com.zopen.ato.autoconfigure;
import com.zopen.ato.properties.WechatWorkProperties;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.client.RestTemplateBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;
@Configuration
@EnableConfigurationProperties(WechatWorkProperties.class)
@ComponentScan("com.zopen.wechat.work")
@ConditionalOnProperty(prefix = "zopen.wechat.work", name = "open", havingValue = "true")
public class WechatWorkAutoConfiguration {
private static final Logger logger = LoggerFactory.getLogger(WechatWorkAutoConfiguration.class);
private final WechatWorkProperties properties;
public WechatWorkAutoConfiguration(WechatWorkProperties properties) {
this.properties = properties;
logger.info("初始化 Wechat 企业微信配置:" + properties);
}
@Bean
@ConditionalOnMissingBean
@ConditionalOnClass(RestTemplate.class)
public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
return restTemplateBuilder.build();
}
}