# 说明
## 三个子项目
- spring-boot-eureka-server,服务注册中心
- spring-boot-eureka-productor,生产者
- spring-boot-eureka-consumer,消费者
## windows下需要修改hosts文件
C:\Windows\System32\drivers\etc
127.0.0.1 peer1
## 搭建步骤
- 搭建服务注册中心
- 创建SpringBoot工程
- 引入spring-boot-starter-eureka-server
- 在启动类贴上@EnabelEurekaServer,代表启动服务注册中心
- 配置application.properties,具体查看spring-boot-eureka-server
- 注册服务提供者
- 创建SpringBoot工程
- 引入spring-boot-starter-web和starter-eureka
- 在启动类贴上@EnabelDiscoveryClient,激活Eureka的DiscoveryClient的实现,
可以在Controller中注入DiscoveryClient client,
```java
ServiceInstance instance = client.getLocalServiceInstance();
instance.getHost();instance.getServiceId();
```
- 配置application.properties,具体查看spring-boot-eureka-productor
- 启动后如果注册成功,注意查看控制台,status:204
- 注册服务消费者
- 拷贝服务提供者,记得修改应用名和端口
- 在启动类中手动注入RestTemplate
```java
@Bean@LoadBalanced
public RestTemplate restTemplate() {return new RestTemplate();}
```
- 在Controller中注入使用
## 疑难杂症
- UnknownHostException
- 检查RestTemplate 是否注册为Bean并且贴上@LoadBalanced
没有合适的资源?快使用搜索试试~ 我知道了~
eureka注册中心,生产者,消费者实例
共433个文件
xml:395个
properties:9个
class:8个
5星 · 超过95%的资源 需积分: 0 16 下载量 200 浏览量
2018-06-10
20:19:50
上传
评论
收藏 311KB RAR 举报
温馨提示
该压缩包包含了3个demo,分别是eureka注册中心,两个eureka客户端,解压后请先查看根目录下的README.md,有助于使用。
资源推荐
资源详情
资源评论
收起资源包目录
eureka注册中心,生产者,消费者实例 (433个子文件)
HelloController.class 1KB
SpringBootEurekaConsumerApplication.class 1KB
ConsumerController.class 1KB
SpringBootEurekaProductorApplication.class 878B
SpringBootEurekaServerApplication.class 865B
SpringBootEurekaProductorApplicationTests.class 723B
SpringBootEurekaConsumerApplicationTests.class 718B
SpringBootEurekaServerApplicationTests.class 708B
mvnw.cmd 5KB
mvnw.cmd 5KB
mvnw.cmd 5KB
.gitignore 268B
.gitignore 268B
.gitignore 268B
maven-wrapper.jar 46KB
maven-wrapper.jar 46KB
maven-wrapper.jar 46KB
HelloController.java 954B
SpringBootEurekaConsumerApplication.java 846B
ConsumerController.java 723B
SpringBootEurekaProductorApplication.java 494B
SpringBootEurekaServerApplication.java 490B
SpringBootEurekaProductorApplicationTests.java 380B
SpringBootEurekaConsumerApplicationTests.java 378B
SpringBootEurekaServerApplicationTests.java 374B
README.md 1KB
mvnw 6KB
mvnw 6KB
mvnw 6KB
application.properties 405B
application.properties 405B
application.properties 142B
application.properties 142B
application.properties 131B
application.properties 131B
maven-wrapper.properties 110B
maven-wrapper.properties 110B
maven-wrapper.properties 110B
workspace.xml 25KB
workspace.xml 21KB
workspace.xml 18KB
workspace.xml 14KB
markdown-navigator.xml 5KB
pom.xml 2KB
pom.xml 2KB
pom.xml 2KB
Project_Default.xml 1KB
Project_Default.xml 1KB
Project_Default.xml 1KB
Project_Default.xml 1KB
Maven__org_springframework_cloud_spring_cloud_starter_netflix_eureka_client_1_4_4_RELEASE.xml 911B
Maven__org_springframework_cloud_spring_cloud_starter_netflix_eureka_client_1_4_4_RELEASE.xml 911B
Maven__org_springframework_cloud_spring_cloud_starter_netflix_eureka_server_1_4_4_RELEASE.xml 911B
Maven__org_springframework_cloud_spring_cloud_starter_netflix_archaius_1_4_4_RELEASE.xml 876B
Maven__org_springframework_cloud_spring_cloud_starter_netflix_archaius_1_4_4_RELEASE.xml 876B
Maven__org_springframework_cloud_spring_cloud_starter_netflix_archaius_1_4_4_RELEASE.xml 876B
Maven__org_springframework_cloud_spring_cloud_starter_netflix_ribbon_1_4_4_RELEASE.xml 862B
Maven__org_springframework_cloud_spring_cloud_starter_netflix_ribbon_1_4_4_RELEASE.xml 862B
Maven__org_springframework_cloud_spring_cloud_starter_netflix_ribbon_1_4_4_RELEASE.xml 862B
Maven__org_springframework_cloud_spring_cloud_netflix_eureka_client_1_4_4_RELEASE.xml 855B
Maven__org_springframework_cloud_spring_cloud_netflix_eureka_client_1_4_4_RELEASE.xml 855B
Maven__org_springframework_cloud_spring_cloud_netflix_eureka_client_1_4_4_RELEASE.xml 855B
Maven__org_springframework_cloud_spring_cloud_starter_eureka_server_1_4_4_RELEASE.xml 855B
Maven__org_springframework_cloud_spring_cloud_netflix_eureka_server_1_4_4_RELEASE.xml 855B
Maven__org_springframework_boot_spring_boot_test_autoconfigure_1_5_13_RELEASE.xml 830B
Maven__org_springframework_boot_spring_boot_test_autoconfigure_1_5_13_RELEASE.xml 830B
Maven__org_springframework_boot_spring_boot_test_autoconfigure_1_5_13_RELEASE.xml 830B
Maven__org_springframework_boot_spring_boot_starter_freemarker_1_5_13_RELEASE.xml 830B
Maven__org_springframework_boot_spring_boot_starter_actuator_1_5_13_RELEASE.xml 816B
Maven__org_springframework_boot_spring_boot_starter_logging_1_5_13_RELEASE.xml 809B
Maven__org_springframework_boot_spring_boot_starter_logging_1_5_13_RELEASE.xml 809B
Maven__org_springframework_boot_spring_boot_starter_logging_1_5_13_RELEASE.xml 809B
Maven__org_springframework_cloud_spring_cloud_starter_eureka_1_4_4_RELEASE.xml 806B
Maven__org_springframework_cloud_spring_cloud_starter_eureka_1_4_4_RELEASE.xml 806B
Maven__org_springframework_boot_spring_boot_starter_tomcat_1_5_13_RELEASE.xml 802B
Maven__org_springframework_boot_spring_boot_starter_tomcat_1_5_13_RELEASE.xml 802B
Maven__org_springframework_boot_spring_boot_starter_tomcat_1_5_13_RELEASE.xml 802B
Maven__com_fasterxml_jackson_module_jackson_module_jaxb_annotations_2_8_11.xml 797B
Maven__org_springframework_boot_spring_boot_autoconfigure_1_5_13_RELEASE.xml 795B
Maven__org_springframework_boot_spring_boot_autoconfigure_1_5_13_RELEASE.xml 795B
Maven__org_springframework_boot_spring_boot_autoconfigure_1_5_13_RELEASE.xml 795B
Maven__org_springframework_cloud_spring_cloud_netflix_core_1_4_4_RELEASE.xml 792B
Maven__org_springframework_cloud_spring_cloud_netflix_core_1_4_4_RELEASE.xml 792B
Maven__org_springframework_cloud_spring_cloud_netflix_core_1_4_4_RELEASE.xml 792B
Maven__org_springframework_boot_spring_boot_starter_test_1_5_13_RELEASE.xml 788B
Maven__org_springframework_boot_spring_boot_starter_test_1_5_13_RELEASE.xml 788B
Maven__org_springframework_boot_spring_boot_starter_test_1_5_13_RELEASE.xml 788B
Maven__org_springframework_security_spring_security_crypto_4_2_6_RELEASE.xml 783B
Maven__org_springframework_security_spring_security_crypto_4_2_6_RELEASE.xml 783B
Maven__org_springframework_security_spring_security_crypto_4_2_6_RELEASE.xml 783B
Maven__org_springframework_boot_spring_boot_starter_web_1_5_13_RELEASE.xml 781B
Maven__org_springframework_boot_spring_boot_starter_web_1_5_13_RELEASE.xml 781B
Maven__org_springframework_boot_spring_boot_starter_web_1_5_13_RELEASE.xml 781B
Maven__org_springframework_security_spring_security_rsa_1_0_3_RELEASE.xml 762B
Maven__org_springframework_security_spring_security_rsa_1_0_3_RELEASE.xml 762B
Maven__org_springframework_security_spring_security_rsa_1_0_3_RELEASE.xml 762B
Maven__org_springframework_boot_spring_boot_actuator_1_5_13_RELEASE.xml 760B
Maven__org_springframework_cloud_spring_cloud_context_1_3_3_RELEASE.xml 757B
Maven__org_springframework_cloud_spring_cloud_starter_1_3_3_RELEASE.xml 757B
Maven__org_springframework_cloud_spring_cloud_commons_1_3_3_RELEASE.xml 757B
共 433 条
- 1
- 2
- 3
- 4
- 5
资源评论
- hlg155418402422019-07-24还不错,可以用!
火车站卖橘子
- 粉丝: 9
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功