All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zopen.ato.autoconfigure.WechatMpAutoConfiguration Maven / Gradle / Ivy

There is a newer version: 1.0.5
Show newest version
package com.zopen.ato.autoconfigure;

import com.zopen.ato.properties.WechatMpProperties;
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(WechatMpProperties.class)
@ComponentScan("com.zopen.wechat.mp")
@ConditionalOnProperty(prefix = "zopen.wechat.mp", name = "open", havingValue = "true")
public class WechatMpAutoConfiguration {

    private static final Logger logger = LoggerFactory.getLogger(WechatMpAutoConfiguration.class);

    private final WechatMpProperties properties;

    public WechatMpAutoConfiguration(WechatMpProperties properties) {
        this.properties = properties;
        logger.info("初始化 Wechat 公众号配置:" + properties);
    }

    @Bean
    @ConditionalOnMissingBean
    @ConditionalOnClass(RestTemplate.class)
    public RestTemplate restTemplate(RestTemplateBuilder restTemplateBuilder) {
        return restTemplateBuilder.build();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy