赞
踩
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-eureka-server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
<!--eureka依赖-->
<dependencies>
<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-eureka-server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka-server</artifactId>
<version>1.4.7.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
</dependency>
</dependencies>
server:
port: 7001
#eureka配置
eureka:
instance:
hostname: localhost #eureka server运行的主机名,所以访问eureka监控页面的url为http://localhost:7001/
client:
register-with-eureka: false
#表示是否向eureka注册中心注册自己,但是由于这个子model本来就是用来充当eureka服务器/注册中心的,所以设置为false
#这个属性设为false同时也就表明了这个微服务是eureka服务器程序
fetch-registry: false #fetch-registry为false表示这个微服务为eureka注册中心
service-url:
defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
#微服务提供者向注册中心的注册服务的地址,它有默认的url,为"http://localhost:8761/eureka/"
#但是我们自己配置了eureka运行的主机名和端口号,所以我们在配置的时候不会将配置写死,而是获取上面我们的配置,这样后面更改的时候就只需要更改上面的显式配置,而不需要更改引用处的值
package com.thhh.springcloud;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer //开启EurekaServer,可以接收其他的服务注册进来
public class EurekaServer_7001 {
public static void main(String[] args) {
SpringApplication.run(EurekaServer_7001.class,args);
}
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。