Create a basic spring boot project, named Eureka-server, and introduce the required dependencies in the Pom.xml:
<parent><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-parent</artifactId><version>1.5.4.RELEASE</version><relativePath/></parent><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-eureka-server</artifactId></dependency></dependencies><dependencyManagement><dependencies><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-dependencies</artifactId><version>Dalston.SR1</version><type>pom</type><scope>import</scope></dependency></dependencies></dependencyManagement>
Start a service registry with @enableeurekaserver annotations to provide conversations to other apps. This step is very simple, just add this annotation to a normal spring boot application to enable this feature, such as the following example:
@EnableEurekaServer@SpringBootApplicationpublic class Application {public static void main(String[] args) {new SpringApplicationBuilder(Application.class).web(true).run(args);}}
By default, the service registry will also attempt to register itself as a client, so we need to disable its client registration behavior by simply adding the following information to the Application.properties configuration file:
spring.application.name=eureka-serverserver.port=1001eureka.instance.hostname=localhosteureka.client.register-with-eureka=falseeureka.client.fetch-registry=false
To differentiate the service from subsequent registrations, the port for the service registry is set to 1001 via the Server.port property. After you start the project, you can see the following page, where no services have been found.
From now on, I will record the process and the essence of the recently developed Springcloud micro-service cloud architecture, and help more friends who are interested in developing the Spring cloud framework, hoping to help more good scholars. Let's explore how the Spring cloud architecture is built and how it can be used in enterprise projects. Source source technical support for complete projects 1791743380
Spring Cloud builds a microservices architecture-Create a service registration center