EurekaServer:
1.依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
2.配置
#basic
server.port=8001
#eureka
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.service-url.defaultZone=http://127.0.0.1:${server.port}/eureka
3.启动
@SpringBootApplication
@EnableEurekaServer
public class EurekaServer {
public static void main(String[] args) {
SpringApplication.run(EurekaServer.class);
}
}
4.测试
http://127.0.0.1:8001/
EurekaClient:
1.依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
2.配置
#eureka
eureka.client.service-url.defaultZone=http://127.0.0.1:8001/eureka
eureka.instance.prefer-ip-address=true
3.启动
@SpringBootApplication
@EnableEurekaClient
public class ArticleApplication {
public static void main(String[] args) {
SpringApplication.run(ArticleApplication.class, args);
}
}
4.测试
http://127.0.0.1:8001/ 中看到Application下有此项目
网友评论