peanut996/blog-comment

Mini Spring Cloud - PEANUT996

Opened this issue · 0 comments

https://peanut996.cn/notes/spring/mini-spring-cloud-doc/

服务注册 代码分支: service-registry
为了演示,写一个非常简单的单机版的服务注册和发现中心,命名图图
@RestController @SpringBootApplication public class TutuServerApplication { private static Logger logger = LoggerFactory.getLogger(TutuServerApplication.class); private ConcurrentHashMap<String, Set> 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.