We build the following for the Eureka project of Honghu Cloud, the whole construction process is simple, I will record every step of the construction process, I hope to help everyone:
- 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& Lt;/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& Gt;spring-cloud-starter-eureka-server</artifactid> </dependency> <dependency> <groupId>org.springframework.boot< /groupid> <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifacti d>spring-boot-devtools</artifactid> </dependency> <dependency> <gro Upid>org.springframework.boot</groupid> <artifactid>spring-boot-starter-test</artifactid> ; <scope>test</scope> </dependency> </dependencies> <build> <PL Ugins> <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&G T <goal>build-info</goal> </goals> </execution> </executions> <configuration> <executable>true</exec utable> </configuration> </plugin> </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 @SpringBootApplication public class ServiceApplication { public static void main(String[] args) { SpringApplication.run(ServiceApplication.class, args); }
- Configuring the Application.yml File
<code class= "language-html" ># Server (Eureka default port: 8761) server:port:8761 # Spring SPRING:APPL Ication:name:particle-commonservice-erueka # Eureka Eureka:client: # Whether to register to Eureka Regi Ster-with-eureka:true # Whether to obtain registration information from Eureka Fetch-registry:false Availability-zones:honghu: Honghuzone Service-url:honghuzone:http://honghu:[email protected]:8761/eureka/defaultzon E:http://honghu:[email protected]:8761/eureka/instance:prefer-ip-address:true Hostname:localh OST metadataMap:zone:honghuZone User: ${security.user.name} password: {SECURITY.USER.P Assword} # Specify Environment Environment:dev #指定数据中心 Datacenter:honghu # Turn off self-protection mode Server:enabl E-self-preservation:false #设置清理无效节点的时间间隔, default 60000, which is 60s eviction-interval-timer-in-ms:60000 # service authentication Secu Rity:basic: Enabled:true User:name:honghu password:123456 Management:security:enabled:fal Se </code>
Increase the log mechanism and package run mechanism of the project (we will write the package deployment mechanism for Linux CentOS in detail later)
- As of this entire project deployment, the run as-to-Spring Boot App is done manually, with the following results:
Console Run Results:
To access the console and log in:
Console Run Effect:
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.
Source source technical support for complete projects 1791743380
Spring Cloud Cloud Service Architecture-Commonservice-eureka Project Process Building