1 Star 0 Fork 0

桂在坚持 / eureka-web

Create your Gitee Account
Explore and code with more than 8 million developers,Free private repositories !:)
Sign up
The current repository's web page is accessible only to members. If you need to make it public, please ask author 桂在坚持 to submit applications.
Clone or Download
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README.md

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

Repository Comments ( 0 )

Sign in to post a comment

About

eureka注册中心搭建 expand collapse
Java
MIT
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
Java
1
https://git.oschina.net/litepal/eureka-web.git
git@git.oschina.net:litepal/eureka-web.git
litepal
eureka-web
eureka-web
master

Search

103111 552b83b3 1850385 103110 ed87a847 1850385