com.feingto.cloud.config.consul.ConsulServiceRegistryAutoConfiguration Maven / Gradle / Ivy
The newest version!
package com.feingto.cloud.config.consul;
import com.ecwid.consul.v1.ConsulClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.cloud.consul.ConditionalOnConsulEnabled;
import org.springframework.cloud.consul.discovery.ConsulDiscoveryProperties;
import org.springframework.cloud.consul.discovery.HeartbeatProperties;
import org.springframework.cloud.consul.discovery.TtlScheduler;
import org.springframework.cloud.consul.serviceregistry.ConsulServiceRegistry;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
* Consul 服务注册自动注入
*
* @author longfei
*/
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(ConsulClient.class)
@ConditionalOnConsulEnabled
public class ConsulServiceRegistryAutoConfiguration {
@Bean
@ConditionalOnMissingBean
public ConsulServiceRegistry consulServiceRegistry(ConsulClient consulClient, ConsulDiscoveryProperties properties,
HeartbeatProperties heartbeatProperties, @Autowired(required = false) TtlScheduler ttlScheduler) {
return new ConsulServiceAutoRegistration(consulClient, properties, ttlScheduler, heartbeatProperties);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy