- Cloud-Native Applications in Java
- Ajay Mahajan Munish Kumar Gupta Shyam Sundar
- 279字
- 2021-06-24 19:07:17
Running a service registry
Consul and Eureka are two popular dynamic service registries. There are subtle conceptual differences between them with respect to the method of heartbeats and agent-based operations, but the fundamental concept of registry is similar. The selection of the registry will be driven by the needs and the decisions of the enterprise. For our example, let's continue with Spring Boot and the Spring Cloud ecosystem and use Eureka for this example. Spring Cloud includes Spring Cloud Netflix, which has support for the Eureka registry.
Perform the following steps to get a service registry running:
- Create a new Maven project with artifactId as eureka-server.
- Edit the POM file and add the following:
- Parent as spring-boot-starter-parent
- The dependency to eureka-server as spring-cloud-starter-eureka-server
- The dependencyManagement to spring-cloud-netflix:

- Create an application class similar to the one we created for the product project. Note the annotations. The annotation @EnableEurekaServer starts Eureka as a service:

- Create an application.yml file in the /product/src/main/resources folder of the application and put in the following:
server: port: 8761
- Create a bootstrap.yml file in the resources folder of the application and put in the following:
spring: application: name: eureka
- Build the eureka-server Maven project (as we did for product) and then run it.
- Apart from a few connectivity errors (more on this later), you should see a Tomcat started message as follows:

Once the startup is completed, access the Eureka server at localhost:8761 and check whether you get the following page:

Look at the circled section in the preceding screenshot. The instance currently registered with Eureka is EUREKA itself. We can correct this later. Now, let's focus on registering our product service with this Eureka service registry.
- 電子技術(shù)綜合知識全精講(雙色版)
- 電子工藝與EDA
- 電子工程師自學(xué)速成:入門篇(第2版)
- 一起玩電子:電子制作入門、拓展全攻略
- 對話物聯(lián)網(wǎng)
- 松下/日立新型彩色電視機(jī)速修圖解
- 光纜與光設(shè)備維護(hù)
- 電子技能與實(shí)訓(xùn)項(xiàng)目教程
- 電路基礎(chǔ)
- 天地一體化信息網(wǎng)絡(luò)架構(gòu)與技術(shù)
- 電子對抗原理
- iOS游戲框架Sprite Kit技術(shù)詳解
- 電子工藝與品質(zhì)管理
- 電子元器件應(yīng)用實(shí)戰(zhàn)
- 現(xiàn)代電子戰(zhàn)系統(tǒng)導(dǎo)論(第二版)