搭建Eureka服务注册中心

去到这个Spring的代码生成网站,网站貌似改版了,感觉以前的好看点儿

https://start.spring.io/

网站目前大概是这个样子的:

group和artifact随意,主要是上面的依赖选择,输入Eureka,选择Eureka Server即可,如果要加验证的话,可以加上Security模块

然后生成工程:

 

然后倒入Eclipse中【其实在Eclipse中安装相关插件也可以建立SpringBoot的工程,建议可以用Spring的STS】

配置一下配置文件:

#spring:
#  security:
#    user:
#      name: admin
#      password: pwd
server:
  port: 8761
eureka:
  instance:
    hostname: localhost
  client:
    register-with-eureka: false
    fetch-registry: false
    service-url:
      defaultZone: http://${eureka.instance.hostname}:${server.port}/

在启动类上加上:@EnableEurekaServer

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@SpringBootApplication
@EnableEurekaServer
public class EurekaDemoApplication {

	public static void main(String[] args) {
		SpringApplication.run(EurekaDemoApplication.class, args);
	}
}

 然后启动访问:localhost:8761/  

 ********************************* 不积跬步无以至千里,不积小流无以成江海 ********************************* 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值