Stones
Know Springcloud for a long time, but has not been learning and practice, just these two days have this impulse, then the strike ...!!!!!
After searching for some information, I found a simple and easy-to-use series of blog http://blog.csdn.net/forezp/article/details/70148833 to take this practiced hand .... Thanks to the knowledge and sharing of the predecessors
————————————————————————————————————————————————————————————————————
1, create the project, I use the IDE here, multiple projects are created together. Create a way to refer to the blog of the Great God, I will not repeat this step.
2, the service side:
Dependencies required by the service side
< dependency > < groupid > org.springframework.cloud</ Span style= "COLOR: #800000" >groupid > < artifactid > Spring-cloud-starter-eureka-server</ Artifactid > </ dependency >
Add @EnableEurekaServer annotations to identify this as a Eureka service
After this is started directly, the access page (the default port is 8080) jumps to
Such a page, but the boot process console will error
So you need to add some configuration
Eureka: instance: hostname:localhost client: register-with-eureka:false fetch-registry: False Service-url: defaultzone:http://${eureka.instance.hostname}:${server.port}/eureka/
Note Both of these: false
3, the Client
Clients need to rely on
< Dependency > < groupId >org.springframework.cloud</groupId> < Artifactid>spring-cloud-starter-eureka</artifactid> </ Dependency >
Plus @EnableEurekaClient identify the client identity
But that's not enough.
The client needs to be registered to the server and the server needs to discover the client
Client-initiated, access to server-side pages
A service was found to be registered. The name and port number are exactly the information that is configured in the client service
============================= to this end, the server and client demo is completed =============================
- The simplest Springcloud tutorial in history | First article: Registration and discovery of services (Eureka)
Service registration and discovery, name concise, thanks to the predecessors to share
But:
What the hell is this?
—————————————————————————————————————————————————————————————————————————
In any case, calm
Springcloud's study (i) Registration and discovery of services