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;@EnableEurekaServer@SpringBootApplicationpublic class ServiceApplication { public static void main(String[] args) { SpringApplication.run(ServiceApplication.class, args); }}
- Configuring the Application.yml File
# server (Eureka default port is: 8761) server:port:8761# Springspring:application:name:particle-commonservice-er ueka# eurekaeureka:client: # Whether to register to Eureka Register-with-eureka:true # whether to get registration information from Eureka Fetch-registry:fals E Availability-zones:honghu:honghuzone Service-url:honghuzone:http://honghu:[email protected]:8 761/eureka/defaultzone:http://honghu:[email protected]:8761/eureka/instance:prefer-ip-address:true h Ostname:localhost metadataMap:zone:honghuZone User: ${security.user.name} password: {SECURITY.USER.PA ssWOrd} # Specify Environment Environment:dev #指定数据中心 Datacenter:honghu # turn off self-protected mode Server:enable-self-preservation:false # Set the time interval for cleanup of invalid nodes, default 60000, which is 60s eviction-interval-timer-in-ms:60000# service authentication security:basic:enabled:true user:n Ame:honghu Password:123456management:security:enabled:false
- Increase the log mechanism and package run mechanism of the project (we will write the package deployment mechanism for Linux CentOS in detail later)
From now on, I will be documenting the process and essence of the recent development of the spring cloud micro-service cloud architecture to help more friends who are interested in developing the Spring cloud framework to explore the process of building the spring cloud architecture and how to use it in enterprise projects.
Spring Cloud Cloud Service architecture-Honghu Commonservice-eureka Project