Spring Cloud Micro-service architecture Eureka

Source: Internet
Author: User
Tags zookeeper

1 Service Discovery
# # About Service discovery
In the MicroServices architecture, Service Discovery (Discovery) is one of the key principles. Manually configuring each client or some form of convention is difficult and fragile. Spring Cloud provides several ways to implement service discovery, such as Eureka, Consul, Zookeeper.
Spring Cloud is best supported by Eureka, followed by Consul, the zookeeper.

2. Create a MAVEN project (Microservice-discovery-eureka) and add the following to the Pom.xml

<Projectxmlns= "http://maven.apache.org/POM/4.0.0"Xmlns:xsi= "Http://www.w3.org/2001/XMLSchema-instance"xsi:schemalocation= "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">    <modelversion>4.0.0</modelversion>    <Artifactid>Microservice-discovery-eureka</Artifactid>    <Packaging>Jar</Packaging>    <Parent>        <groupId>Com.xujin.study</groupId>        <Artifactid>Microservice-spring-cloud</Artifactid>        <version>0.0.1-snapshot</version>        <RelativePath/> <!--Lookup parent from repository -    </Parent>    <Properties>        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>    </Properties>    <Dependencies>        <Dependency>            <groupId>Org.springframework.cloud</groupId>            <Artifactid>Spring-cloud-starter-eureka-server</Artifactid>        </Dependency>        <Dependency>            <groupId>Org.springframework.boot</groupId>            <Artifactid>Spring-boot-starter-security</Artifactid>        </Dependency>    </Dependencies></Project>

3. Create Startup Class Eurekaapplication

 PackageCom.xujin.study;Importorg.springframework.boot.SpringApplication;Importorg.springframework.boot.autoconfigure.SpringBootApplication;Importorg.springframework.cloud.netflix.eureka.server.enableeurekaserver;@ Springbootapplication@enableeurekaserver Public classeurekaapplication { Public Static voidMain (string[] args) {Springapplication.run (eurekaapplication.class, args); }}

4, Configuration Eureka

Server:  port:8761                    # Specifies the port of the Eureka Instance security:  Basic:    enabled:true  User:    name:root    Password:rooteureka:  instance:    hostname:discovery         # Specifies the host name of the Eureka instance  client:    Registerwitheureka:false    fetchregistry:false    serviceurl:      defaultzone:http://${ security.user.name}:${security.user.password}@${eureka.instance.hostname}:${server.port}/eureka/
5. After starting the project, visit: [http://127.0.0.1:8761/] Enter your configured user name and password to enter the Eureka page

Spring Cloud Micro-service architecture Eureka

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.