application.yml
server: port: 8888eureka: instance: hostname: localhost client: service-url: defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/ register-with-eureka: false #值为false意味着自身仅作为服务器,不作为客户端 fetch-registry: false #值为false意味着无需注册自身 server: enable-self-preservation: false
application.properties
server.port: 8761eureka.instance.hostname: localhosteureka.client.registerWithEureka: falseeureka.client.fetchRegistry: falseeureka.client.serviceUrl.defaultZone: http://${eureka.instance.hostname}:${server.port}/eureka/
Application
package com.xp.cn;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;@SpringBootApplication@EnableEurekaServerpublic class EurekaApp { public static void main(String[] args) { SpringApplication.run(EurekaApp.class, args); }}
spring boot启动报错:No active profile set, falling back to default profiles: default
参考文档:https://github.com/Netflix/eureka/wiki/Eureka-at-a-glance
springCloud: http://projects.spring.io/spring-cloud/spring-cloud.html#_service_discovery_eureka_clients