commit
b4e6ccd888
@ -0,0 +1,7 @@
|
||||
out/
|
||||
target/
|
||||
.idea/
|
||||
.idea_modules/
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
After Width: | Height: | Size: 328 KiB |
After Width: | Height: | Size: 51 KiB |
After Width: | Height: | Size: 8.3 KiB |
@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>mini-spring-cloud</artifactId>
|
||||
<groupId>com.github</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>mini-spring-cloud-provider-example</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github</groupId>
|
||||
<artifactId>mini-spring-cloud-tutu-discovery</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,28 @@
|
||||
package com.github.cloud.examples;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* @author derek(易仁川)
|
||||
* @date 2022/3/19
|
||||
*/
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
public class ProviderApplication {
|
||||
|
||||
@Value("${server.port}")
|
||||
private Integer port;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(ProviderApplication.class, args);
|
||||
}
|
||||
|
||||
@PostMapping("/echo")
|
||||
public String echo() {
|
||||
return "Port of the service provider: " + port;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
spring:
|
||||
application:
|
||||
name: provider-application
|
||||
cloud:
|
||||
tutu:
|
||||
discovery:
|
||||
server-addr: localhost:6688
|
||||
service: ${spring.application.name}
|
||||
|
||||
# 随机端口
|
||||
server:
|
||||
port: ${random.int[10000,20000]}
|
@ -0,0 +1,41 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>mini-spring-cloud</artifactId>
|
||||
<groupId>com.github</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>tutu-server</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,133 @@
|
||||
package com.github.cloud.examples;
|
||||
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author derek(易仁川)
|
||||
* @date 2022/3/19
|
||||
*/
|
||||
|
||||
@RestController
|
||||
@SpringBootApplication
|
||||
public class TutuServerApplication {
|
||||
private static Logger logger = LoggerFactory.getLogger(TutuServerApplication.class);
|
||||
|
||||
private ConcurrentHashMap<String, Set<Server>> serverMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(TutuServerApplication.class, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务注册
|
||||
*
|
||||
* @param serviceName
|
||||
* @param ip
|
||||
* @param port
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("register")
|
||||
public boolean register(@RequestParam("serviceName") String serviceName, @RequestParam("ip") String ip, @RequestParam("port") Integer port) {
|
||||
logger.info("register service, serviceName: {}, ip: {}, port: {}", serviceName, ip, port);
|
||||
serverMap.putIfAbsent(serviceName.toLowerCase(), Collections.synchronizedSet(new HashSet<>()));
|
||||
Server server = new Server(ip, port);
|
||||
serverMap.get(serviceName).add(server);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务注销
|
||||
*
|
||||
* @param serviceName
|
||||
* @param ip
|
||||
* @param port
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("deregister")
|
||||
public boolean deregister(@RequestParam("serviceName") String serviceName, @RequestParam("ip") String ip, @RequestParam("port") Integer port) {
|
||||
logger.info("deregister service, serviceName: {}, ip: {}, port: {}", serviceName, ip, port);
|
||||
Set<Server> serverSet = serverMap.get(serviceName.toLowerCase());
|
||||
if (serverSet != null) {
|
||||
Server server = new Server(ip, port);
|
||||
serverSet.remove(server);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据服务名称查询服务列表
|
||||
*
|
||||
* @param serviceName
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("list")
|
||||
public Set<Server> list(@RequestParam("serviceName") String serviceName) {
|
||||
Set<Server> serverSet = serverMap.get(serviceName.toLowerCase());
|
||||
logger.info("list service, serviceName: {}, serverSet: {}", serviceName, JSON.toJSONString(serverSet));
|
||||
return serverSet != null ? serverSet : Collections.emptySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询所有服务名称列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("listServiceNames")
|
||||
public Enumeration<String> listServiceNames() {
|
||||
return serverMap.keys();
|
||||
}
|
||||
|
||||
/**
|
||||
* 服务
|
||||
*/
|
||||
public static class Server {
|
||||
private String ip;
|
||||
|
||||
private Integer port;
|
||||
|
||||
public Server(String ip, Integer port) {
|
||||
this.ip = ip;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public Integer getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Server server = (Server) o;
|
||||
|
||||
if (!ip.equals(server.ip)) return false;
|
||||
return port.equals(server.port);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ip.hashCode();
|
||||
result = 31 * result + port.hashCode();
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
server:
|
||||
port: 6688
|
@ -0,0 +1,67 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>mini-spring-cloud</artifactId>
|
||||
<groupId>com.github</groupId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>mini-spring-cloud-tutu-discovery</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-autoconfigure</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-commons</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-context</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -0,0 +1,77 @@
|
||||
package com.github.cloud.tutu;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||
import org.springframework.cloud.commons.util.InetUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import javax.annotation.PostConstruct;
|
||||
|
||||
/**
|
||||
* @author derek(易仁川)
|
||||
* @date 2022/3/19
|
||||
*/
|
||||
@ConfigurationProperties("spring.cloud.tutu.discovery")
|
||||
public class TutuDiscoveryProperties {
|
||||
|
||||
@Autowired
|
||||
private InetUtils inetUtils;
|
||||
|
||||
private String serverAddr;
|
||||
|
||||
private String service;
|
||||
|
||||
private String ip;
|
||||
|
||||
private int port = -1;
|
||||
|
||||
private boolean secure = false;
|
||||
|
||||
@PostConstruct
|
||||
public void init() throws Exception {
|
||||
if (!StringUtils.hasLength(ip)) {
|
||||
//获取服务IP地址
|
||||
ip = inetUtils.findFirstNonLoopbackHostInfo().getIpAddress();
|
||||
}
|
||||
}
|
||||
|
||||
public String getServerAddr() {
|
||||
return serverAddr;
|
||||
}
|
||||
|
||||
public void setServerAddr(String serverAddr) {
|
||||
this.serverAddr = serverAddr;
|
||||
}
|
||||
|
||||
public String getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
public void setService(String service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
public String getIp() {
|
||||
return ip;
|
||||
}
|
||||
|
||||
public void setIp(String ip) {
|
||||
this.ip = ip;
|
||||
}
|
||||
|
||||
public int getPort() {
|
||||
return port;
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public boolean isSecure() {
|
||||
return secure;
|
||||
}
|
||||
|
||||
public void setSecure(boolean secure) {
|
||||
this.secure = secure;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package com.github.cloud.tutu.registry;
|
||||
|
||||
import org.springframework.cloud.client.serviceregistry.AbstractAutoServiceRegistration;
|
||||
import org.springframework.cloud.client.serviceregistry.Registration;
|
||||
import org.springframework.cloud.client.serviceregistry.ServiceRegistry;
|
||||
|
||||
/**
|
||||
* 服务自动注册
|
||||
*
|
||||
* @author derek(易仁川)
|
||||
* @date 2022/3/19
|
||||
*/
|
||||
public class TutuAutoServiceRegistration extends AbstractAutoServiceRegistration<Registration> {
|
||||
|
||||
private TutuRegistration tutuRegistration;
|
||||
|
||||
protected TutuAutoServiceRegistration(ServiceRegistry<Registration> serviceRegistry, TutuRegistration tutuRegistration) {
|
||||
super(serviceRegistry, null);
|
||||
this.tutuRegistration = tutuRegistration;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Registration getRegistration() {
|
||||
if (tutuRegistration.getPort() < 0) {
|
||||
//设置服务端口
|
||||
tutuRegistration.setPort(this.getPort().get());
|
||||
}
|
||||
return tutuRegistration;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object getConfiguration() {
|
||||
return tutuRegistration.getTutuDiscoveryProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isEnabled() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Registration getManagementRegistration() {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,61 @@
|
||||
package com.github.cloud.tutu.registry;
|
||||
|
||||
import com.github.cloud.tutu.TutuDiscoveryProperties;
|
||||
import org.springframework.cloud.client.DefaultServiceInstance;
|
||||
import org.springframework.cloud.client.serviceregistry.Registration;
|
||||
|
||||
import java.net.URI;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* tutu服务
|
||||
*
|
||||
* @author derek(易仁川)
|
||||
* @date 2022/3/19
|
||||
*/
|
||||
public class TutuRegistration implements Registration {
|
||||
|
||||
private TutuDiscoveryProperties tutuDiscoveryProperties;
|
||||
|
||||
public TutuRegistration(TutuDiscoveryProperties tutuDiscoveryProperties) {
|
||||
this.tutuDiscoveryProperties = tutuDiscoveryProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServiceId() {
|
||||
return tutuDiscoveryProperties.getService();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHost() {
|
||||
return tutuDiscoveryProperties.getIp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getPort() {
|
||||
return tutuDiscoveryProperties.getPort();
|
||||
}
|
||||
|
||||
public void setPort(int port) {
|
||||
this.tutuDiscoveryProperties.setPort(port);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSecure() {
|
||||
return tutuDiscoveryProperties.isSecure();
|
||||
}
|
||||
|
||||
@Override
|
||||
public URI getUri() {
|
||||
return DefaultServiceInstance.getUri(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getMetadata() {
|
||||
return null;
|
||||
}
|
||||
|
||||
public TutuDiscoveryProperties getTutuDiscoveryProperties() {
|
||||
return tutuDiscoveryProperties;
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package com.github.cloud.tutu.registry;
|
||||
|
||||
import cn.hutool.http.HttpUtil;
|
||||
import com.github.cloud.tutu.TutuDiscoveryProperties;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.cloud.client.serviceregistry.Registration;
|
||||
import org.springframework.cloud.client.serviceregistry.ServiceRegistry;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 具体的服务注册实现类
|
||||
*
|
||||
* @author derek(易仁川)
|
||||
* @date 2022/3/19
|
||||
*/
|
||||
public class TutuServiceRegistry implements ServiceRegistry<Registration> {
|
||||
private static final Logger logger = LoggerFactory.getLogger(TutuServiceRegistry.class);
|
||||
|
||||
private TutuDiscoveryProperties tutuDiscoveryProperties;
|
||||
|
||||
public TutuServiceRegistry(TutuDiscoveryProperties tutuDiscoveryProperties) {
|
||||
this.tutuDiscoveryProperties = tutuDiscoveryProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* 注册服务实例
|
||||
*
|
||||
* @param registration
|
||||
*/
|
||||
@Override
|
||||
public void register(Registration registration) {
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("serviceName", tutuDiscoveryProperties.getService());
|
||||
param.put("ip", tutuDiscoveryProperties.getIp());
|
||||
param.put("port", tutuDiscoveryProperties.getPort());
|
||||
|
||||
String result = HttpUtil.post(tutuDiscoveryProperties.getServerAddr() + "/register", param);
|
||||
if (Boolean.parseBoolean(result)) {
|
||||
logger.info("register service successfully, serviceName: {}, ip: {}, port: {}",
|
||||
tutuDiscoveryProperties.getService(), tutuDiscoveryProperties.getIp(), tutuDiscoveryProperties.getPort());
|
||||
} else {
|
||||
logger.error("register service failed, serviceName: {}, ip: {}, port: {}",
|
||||
tutuDiscoveryProperties.getService(), tutuDiscoveryProperties.getIp(), tutuDiscoveryProperties.getPort());
|
||||
throw new RuntimeException("register service failed, serviceName");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 注销服务实例
|
||||
*
|
||||
* @param registration
|
||||
*/
|
||||
@Override
|
||||
public void deregister(Registration registration) {
|
||||
Map<String, Object> param = new HashMap<>();
|
||||
param.put("serviceName", tutuDiscoveryProperties.getService());
|
||||
param.put("ip", tutuDiscoveryProperties.getIp());
|
||||
param.put("port", tutuDiscoveryProperties.getPort());
|
||||
|
||||
String result = HttpUtil.post(tutuDiscoveryProperties.getServerAddr() + "/deregister", param);
|
||||
if (Boolean.parseBoolean(result)) {
|
||||
logger.info("de-register service successfully, serviceName: {}, ip: {}, port: {}",
|
||||
tutuDiscoveryProperties.getService(), tutuDiscoveryProperties.getIp(), tutuDiscoveryProperties.getPort());
|
||||
} else {
|
||||
logger.warn("de-register service failed, serviceName: {}, ip: {}, port: {}",
|
||||
tutuDiscoveryProperties.getService(), tutuDiscoveryProperties.getIp(), tutuDiscoveryProperties.getPort());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatus(Registration registration, String status) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T getStatus(Registration registration) {
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package com.github.cloud.tutu.registry;
|
||||
|
||||
import com.github.cloud.tutu.TutuDiscoveryProperties;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.cloud.client.serviceregistry.Registration;
|
||||
import org.springframework.cloud.client.serviceregistry.ServiceRegistry;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
/**
|
||||
* 自动配置服务注册相关类
|
||||
*
|
||||
* @author derek(易仁川)
|
||||
* @date 2022/3/19
|
||||
*/
|
||||
@Configuration
|
||||
@ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true)
|
||||
public class TutuServiceRegistryAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
public TutuDiscoveryProperties tutuProperties() {
|
||||
return new TutuDiscoveryProperties();
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TutuRegistration tutuRegistration(TutuDiscoveryProperties tutuDiscoveryProperties) {
|
||||
return new TutuRegistration(tutuDiscoveryProperties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TutuServiceRegistry tutuServiceRegistry(TutuDiscoveryProperties tutuDiscoveryProperties) {
|
||||
return new TutuServiceRegistry(tutuDiscoveryProperties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
public TutuAutoServiceRegistration tutuAutoServiceRegistration(ServiceRegistry<Registration> serviceRegistry, TutuRegistration tutuRegistration) {
|
||||
return new TutuAutoServiceRegistration(serviceRegistry, tutuRegistration);
|
||||
}
|
||||
}
|
@ -0,0 +1,2 @@
|
||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||
com.github.cloud.tutu.registry.TutuServiceRegistryAutoConfiguration
|
@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-build</artifactId>
|
||||
<version>3.1.1</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
|
||||
<groupId>com.github</groupId>
|
||||
<artifactId>mini-spring-cloud</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
|
||||
<modules>
|
||||
<module>mini-spring-cloud-examples/tutu-server</module>
|
||||
<module>mini-spring-cloud-tutu-discovery</module>
|
||||
<module>mini-spring-cloud-examples/mini-spring-cloud-provider-example</module>
|
||||
</modules>
|
||||
|
||||
<properties>
|
||||
<spring.cloud.version>2021.0.1</spring.cloud.version>
|
||||
<fastjson.version>1.2.79</fastjson.version>
|
||||
<hutool.version>5.7.21</hutool.version>
|
||||
</properties>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-dependencies</artifactId>
|
||||
<version>${spring-boot.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-dependencies</artifactId>
|
||||
<version>${spring.cloud.version}</version>
|
||||
<type>pom</type>
|
||||
<scope>import</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.github</groupId>
|
||||
<artifactId>mini-spring-cloud-tutu-discovery</artifactId>
|
||||
<version>1.0.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.alibaba</groupId>
|
||||
<artifactId>fastjson</artifactId>
|
||||
<version>${fastjson.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
</project>
|
Loading…
Reference in new issue