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:
- 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> <g Roupid>com.ml.honghu</groupid> <artifactId>particle-commonservice</artifactId> <vers Ion>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> <depen Dency> <groupId>org.springframework.cloud</groupId> <artifactid>spring-cloud-st Arter-eureka-server</artifactid> </dependency&Gt <dependency> <groupId>org.springframework.boot</groupId> <artifactid>spring- boot-starter-security</artifactid> </dependency> <dependency> <groupid>or G.springframework.boot</groupid> <artifactId>spring-boot-devtools</artifactId> </de pendency> <dependency> <groupId>org.springframework.boot</groupId> <a Rtifactid>spring-boot-starter-test</artifactid> <scope>test</scope> </dependency > </dependencies> <build> <plugins> <plugin> <groupid >org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <id>1</id> <goals> <goal>repackage</goal> </goals> </execution> <execution> <id>2</id> <goals> <goal>build-info</goal> < ;/goals> </execution> </executions> <configuration> <executable>true</executable> </configuration> </plugin& Gt </plugins> </build></project>
- 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下的打包部署机制)从现在开始,我这边会将近期研发的spring cloud微服务云架构的搭建过程和精髓记录下来,帮助更多有兴趣研发spring cloud框架的朋友,大家来一起探讨spring cloud架构的搭建过程及如何运用于企业项目。
Spring Cloud Cloud Service Architecture-eureka Project