1 Star 0 Fork 0

桂在坚持 / eureka-web

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Eureka注册中心搭建

一、创建项目

创建项目1

1.1 创建spring boot项目

1.2 配置项目信息

1.3 选择Spring Cloud注册中心

二、配置application

package com.eureka.web;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

@EnableEurekaServer //添加注册中心服务注解
@SpringBootApplication
public class EurekaWebApplication {
    public static void main(String[] args) throws UnknownHostException {
        ConfigurableApplicationContext application = SpringApplication.run(EurekaWebApplication.class, args);
        Environment env = application.getEnvironment();
        String appName = env.getProperty("spring.application.name");
        String host = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        System.out.println(appName + "访问路径:\nhttp://" + host + ":" + port);
    }
}

三、配置application.properties文件

#应用名
spring.application.name=eureka-web
#端口
server.port=1111
eureka.instance.hostname=localhost
# 本应用为注册中心,设置false,表示不向注册中心注册自己
eureka.client.register-with-eureka=false
# 注册中心的职责是维护服务实例,并不需要去检索服务,设置false
eureka.client.fetch-registry=false
# 替换注册中心默认服务路径,默认:String DEFAULT_URL = "http://localhost:8761/eureka/";
eureka.client.service-url.defaultZone=http://${eureka.instance.hostname}:${server.port}/eureka/

四、启动注册中心

eureka-web访问路径:
  http://192.168.0.38:1111

五、源码

https://gitee.com/litepal/eureka-web

MIT License Copyright (c) 2020 桂在坚持 Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

eureka注册中心搭建 展开 收起
Java
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Java
1
https://gitee.com/litepal/eureka-web.git
git@gitee.com:litepal/eureka-web.git
litepal
eureka-web
eureka-web
master

搜索帮助