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 code
- <? 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-starter-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-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.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>
- </plugins>
- </Build>
- </Project>
2. In the Boot class entry reference Eureka configuration, the code is as follows:
Java code
- 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
XML code
- # 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
- Fetch-registry:false
- Availability-zones:
- Honghu:honghuzone
- Service-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. 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 of information source
Integrate spring Cloud cloud service architecture-Commonservice-eureka project build process