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:
1. Create a MAVEN project named Particle-common-eureka, inheriting Particle-commonservice, with the following pom.xml configuration file:
<?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-eur Eka</artifactid> <packaging>jar</packaging> <name>particle-commonservice-eureka</na Me> <description>particle-commonservice Project for Spring boot</description> <dependencies& Gt <dependency> <groupId>org.springframework.cloud</groupId> <ARTIFACTID>SP Ring-cloud-starter-eureka-server</artifactid> </dependency> <dependency> <groupid>org.springframework. Boot</groupid> <artifactId>spring-boot-starter-security</artifactId> </dependen cy> <dependency> <groupId>org.springframework.boot</groupId> <a Rtifactid>spring-boot-devtools</artifactid> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-starter-test </artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupid>org.springframe Work.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> </go als> </execution> </executions> <configuration> ; <executable>true</executable> </configuration> </plug in> </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; @EnableEurekaServer @SpringBootApplication Public class Serviceapplication {public static void main ( String[] args) { springapplication.run (serviceapplication.class, args); } }
3. Configuring the Application.yml File
# 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 # whether to get registration information from Eureka F Etch-registry:false Availability-zones:honghu:honghuzone Service-url:honghuzone:http://hong Hu:[email protected]:8761/eureka/defaultzone:http://honghu:[email protected]:8761/eureka/instance: Prefer-ip-address:true hostname:localhost metadataMap:zone:honghuZone User: ${security.us Er.name} password: {security.user.password} # Specify environment Environment:dev #指定数据中心 Datacenter:honghu # Turn off self-protection mode Server:enable-self-preservation:false #设置清理无效节点的时间间隔, default 60000, which is 60s eviction-interval-time R-IN-MS:60000 # Service Certified security:basic:enabled:true User:name:honghu password:123456 ma Nagement:security: Enabled:false
4. Add the log mechanism of the project and the package operation mechanism (we will write the package deployment mechanism for Linux CentOS in detail later)
5. From the completion of this entire project deployment, the run as-to-Spring Boot App is performed 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
Spring Cloud Cloud Service architecture-Commonservice-eureka project build process