io.github.dengchen2020.ip.config.IpAutoConfiguration Maven / Gradle / Ivy
package io.github.dengchen2020.ip.config;
import io.github.dengchen2020.ip.properties.IpBuilder;
import io.github.dengchen2020.ip.service.IpService;
import io.github.dengchen2020.ip.service.impl.xdb.IpXdbServiceImpl;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
/**
* ip查询配置
* @author dengchen
* @since 2023/5/6
*/
@PropertySource("classpath:application-ip.properties")
@EnableConfigurationProperties(IpBuilder.class)
@Configuration(proxyBeanMethods = false)
public class IpAutoConfiguration {
private final IpBuilder ipBuilder;
public IpAutoConfiguration(IpBuilder ipBuilder) {
this.ipBuilder = ipBuilder;
}
@ConditionalOnMissingBean
@Bean
public IpService ipService(){
return new IpXdbServiceImpl(ipBuilder.getWindows().getLocation(),ipBuilder.getLinux().getLocation());
}
}