Springcloud Architecture Construction (i) Eureka Server Setup and configuration

Source: Internet
Author: User

Springcloud Architecture Construction (i) Eureka Server Setup and configuration
Start today to learn about Springcloud's knowledge and environment deployment, and to build a set of Springcloud distributed frameworks:

This article is only for the first contact or no contact with the small white Springcloud
If there are any deficiencies, please point out in time
The purpose of this blog is mainly to learn to communicate and progress together.
The first step is to create a common Springboot project
You can quickly create a boot project by doing the following:

    1. The browser accesses the http://start.spring.io/, fills in the information, downloads the zip package, and uses it to compress the workspace directly into your IDE.
    2. Use idea to automatically generate the boot project (if you have not created your own Baidu ... )
    3. Create a boot project with eclipse (if you have not created your own Baidu ... )

The second step is to add a dependency in Pom.xml (my full dependency is below)

<project xmlns= "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/maven-v4_0_0.xsd" > <modelversion >4.0.0</modelVersion> <groupId>com.eureka.server</groupId> <artifactId> eureka-server-001</artifactid> <version>0.0.1</version> <name>eureka-server-001 Maven webapp</name> <url>http://maven.apache.org</url> <parent> &LT;GROUPID&GT;ORG.SPRINGFR Amework.boot</groupid> <artifactId>spring-boot-starter-parent</artifactId> <version> 1.5.4.release</version> <relativepath/> </parent> <properties> <project.bu Ild.sourceencoding>utf-8</project.build.sourceencoding> <project.reporting.outputencoding>utf-8 </project.reporting.outputEncoding> &LT;JAVA.VERSION&GT;1.8</java.version> <spring-cloud.version>Dalston.SR4</spring-cloud.version> </properties&    Gt <dependencies> <dependency> <groupId>junit</groupId> &LT;ARTIFACTID&G T;junit</artifactid> <scope>test</scope> </dependency> <!--Spring Clo            UD basic Data Add-<dependency> <groupId>org.springframework.cloud</groupId> <artifactId>spring-cloud-starter-eureka-server</artifactId> </dependency> &LT;DEPENDENCY&G            T <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-starter-test</artifact id> <scope>test</scope> </dependency> <dependency> <grou    Pid>org.springframework.cloud</groupid> <artifactId>spring-cloud-netflix-core</artifactId>     </dependency> <dependency> <groupId>com.google.guava</groupId> &             Lt;artifactid>guava</artifactid> </dependency> <!--hot Deployment plug-in <dependency> <groupId>org.springframework</groupId> <artifactid>springloaded</artifactid&gt        ; </dependency> <!--Hot Deployment--<dependency> <groupid>org.springframework.boot </groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</ Optional> </dependency> <!--Spring Boot admin---<dependency> &LT;GR            Oupid>de.codecentric</groupid> <artifactId>spring-boot-admin-starter-client</artifactId> <version>1.3.2</version> </dependency> <dependency> <groupid >org.springfRamework.boot</groupid> <artifactId>spring-boot-starter-actuator</artifactId> &LT;/DEP endency> <dependency> <groupId>org.jolokia</groupId> <artifactid>j            Olokia-core</artifactid> </dependency> <!--safety certification--<dependency> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-starter-security</arti             factid> </dependency> </dependencies> <dependencyManagement> <dependencies> <dependency> <groupId>org.springframework.cloud</groupId> < Artifactid>spring-cloud-dependencies</artifactid> <version>${spring-cloud.version}</versi on> <type>pom</type> <scope>import</scope> </depend Ency> &LT;/DEPendencies> </dependencyManagement> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-maven-plugin&lt ;/artifactid> </plugin> </plugins> </build></project>

Step three, modify the configuration file Application-dev.properties
To modify the Application.properties file name to Application-dev.properties. This is the
Add content

for the production environment

#appname默认spring. application.name=eureka-h.a. #注册端口号server. port=8761#----------------------- Author-related Information----------------------#-----------------------writer related information----------------------info.owner=lty[email  protected]@[email protected]@[email protected]@[email protected]@[email protected]@# Safety Certification Security.basic.enabled=falsesecurity.user.name=adminsecurity.user.password=123456spring.boot.admin.url= http://localhost:8080#------------------------Service and discovery information---------------------#------------------------ Service and discovery related information---------------------#不使用主机名来定义注册中心的地址, in the form of an IP address, if a property is set, the IP configured with that property is used, otherwise the first IP address other than the loop IP is automatically acquired # Show Ipeureka.instance.prefer-ip-address=true#ip address when registering #eureka.instance.ip-address=localhost# Whether to register as a service eureka.client.register-with-eureka=false# whether to retrieve the service eureka.client.fetch-registry=false# Sets the host name of the current instance eureka.instance.hostname=localhost# defines the call interval for the service Renewal Task (Heartbeat), Units: Seconds eureka.instance.lease-renewal-interval-in-seconds=30# Define when the service expires, Units: Seconds eureka.instance.lease-expiration-duration-in-seconds=90# Status page URL, relative path, default use HTTP access, if you need to use HTTPS, requires an absolute path to configure the URL of the eureka.instance.status-page-url-path=/info# Health Check page, the relative path, the default HTTP access, if you need to use HTTPS requires the URL of the eureka.instance.health-check-url-path=/health# Health Check page to be configured with an absolute path, absolute path eureka.instance.health-check-url= /#关闭注册中心的保护机制, Eureka will count less than 85% of the heartbeat failure within 15 minutes. The protection mechanism will be triggered, the service provider will not be excluded, if the service registry is closed, the unavailable instance is properly rejected # turn off self-protection (open this option during production) eureka.server.enable-self-preservation=true# Scan failed service interval (default is 60* 1000MS) Eureka.server.eviction-interval-timer-in-ms=5000#eureka address of default space eureka.client.service-url.defaultzone= http://localhost:8761/eureka/

Fourth step, add application.yml

spring:   profiles:     active: dev

Fifth step, modify the Application class
Add annotations
@EnableEurekaServer This note indicates that the application is a Eureka service, has the ability to federate multiple services as a cluster, and provides service registration and discovery capabilities
@SpringBootApplication (the boot annotations that were created by the boot project are loaded with some configuration)

Modify the main () method

public static void main(String[] args) {        new SpringApplicationBuilder(EurekaServerApplication.class).web(true).run(args);    }

Sixth step, start the application class
Write a picture description here

Configuration Complete!

Springcloud Architecture Construction (i) Eureka Server Setup and configuration

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.