Spring Cloud Cloud Service architecture-Honghu Commonservice-eureka Project

Source: Internet
Author: User

We reviewed the basics of Spring Cloud Eureka, and now we build on the Eureka project for Honghu Cloud, the entire build process is simple, and I'll record every step of the build process to help you:

  1. Create a Maven project named Particle-common-eureka, which inherits the Particle-commonservice, and the specific pom.xml configuration file is as follows:

    <?xml version= "1.0" encoding= "UTF-8"? ><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/xsd/maven-4.0.0.xsd "><modelVersion>4.0.0</modelVersion><parent> < Groupid>com.ml.honghu</groupid> <artifactId>particle-commonservice</artifactId> <version >0.0.1-snapshot</version></parent><artifactid>particle-commonservice-eureka</ artifactid><packaging>jar</packaging><name>particle-commonservice-eureka</name>< Description>particle-commonservice Project for Spring boot</description><dependencies> < Dependency> <groupId>org.springframework.cloud</groupId> <artifactid>spring-cloud-start er-eureka-server</artifactid> </dependency> <dependency> <groupid>org.springframewOrk.boot</groupid> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-d evtools</artifactid> </dependency> <dependency> <groupId>org.springframework.boot<    /groupid> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency></dependencies><build> <plugins> <plugin> <groupid&gt            ;org.springframework.boot</groupid> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <id>1</id> <g oals> <goal>repackage</goal> </goals> </e            Xecution>    <execution> <id>2</id> <goals> &L t;goal>build-info</goal> </goals> </execution> </exec utions> <configuration> <executable>true</executable> </confi Guration> </plugin> </plugins></build></project>
  2. In the Boot class entry reference Eureka configuration, the code is as follows:
    package com.ml.honghu;

Import org.springframework.boot.SpringApplication;
Import org.springframework.boot.autoconfigure.SpringBootApplication;
Import Org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;

@EnableEurekaServerbr/> @SpringBootApplication
< p="">

public static void main(String[] args) {    SpringApplication.run(ServiceApplication.class, args);}

}

3. 配置application.yml文件
Server (Eureka default port is: 8761)

Server
port:8761

Spring

Spring
Application:
Name:particle-commonservice-erueka

Eureka

Eureka
Client

Whether to register to Eureka
register-with-eureka: true# 是否从eureka获取注册信息fetch-registry: falseavailability-zones:   honghu: honghuZoneservice-url:   honghuZone: http://honghu:[email protected]:8761/eureka/  defaultZone: http://honghu:[email protected]:8761/eureka/

Instance
Prefer-ip-address:true
Hostname:localhost
Metadatamap:
Zone:honghuzone
User: ${security.user.name}
Password: {Security.user.password}

Specify the environment

Environment:dev
#指定数据中心
Datacenter:honghu

Turn off self-protection mode

Server
Enable-self-preservation:false
#设置清理无效节点的时间间隔, default 60000, which is 60s
eviction-interval-timer-in-ms:60000

Service Certification

Security
Basic
Enabled:true
User
Name:honghu
password:123456

Management
Security
Enabled:false

4. 增加项目的log机制和打包运行机制(后面我们会详细编写针对于Linux Centos下的打包部署机制)5. 自此整个项目部署完成

Spring Cloud Cloud Service architecture-Honghu Commonservice-eureka Project

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.