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& Gt;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.s Pringframework.cloud</groupid> <artifactId>spring-cloud-starter-eureka-server</artifactId> </dependency> <dependency> <groupid>org.springframework.boot</groupid& Gt <artifactId>spring-boot-starter-security</artifactId> </dependency> <dependency> <groupId>org.springframework.boot</groupId> <artifactid>spring-boot-devtools& lt;/artifactid> </dependency> <dependency> <groupid>org.spri Ngframework.boot</groupid> <artifactId>spring-boot-starter-test</artifactId> & lt;scope>test</scope> </dependency> </dependencies> <build> < ;p LuginS> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> & Lt;execution> <id>1</id> <goals> <goal>repackage</goal> </goals> </execution& Gt <execution> <id>2</id> <goals> <goal>build-info</goal> </goals> </executio n> </executions> <configuration> <executable>true</executable> </configuration> </plugin> </p Lugins> </build> </project>
2. In the Boot class entry reference Eureka configuration, the code is as follows:
PackageCom.ml.honghu; Importorg.springframework.boot.SpringApplication; Importorg.springframework.boot.autoconfigure.SpringBootApplication; ImportOrg.springframework.cloud.netflix.eureka.server.EnableEurekaServer; @EnableEurekaServer @SpringBootApplication Public classserviceapplication { Public Static voidMain (string[] args) {Springapplication.run (serviceapplication.class, args); } }
3. Configuring the Application.yml File
<codeclass= "language-html" ># Server (Eureka default port is: 8761) Server:port:8761# Spring Spring:application:name:particle-commonservice-Erueka # Eureka eureka:client: # Register to Eureka Register-with-eureka:true# Whether to get registration information from Eureka Fetch-registry:falseAvailability-Zones:honghu:honghuZone Service-url:honghuZone:http://Honghu:[email protected]:8761/eureka/Defaultzone:http://Honghu:[email protected]:8761/eureka/Instance:prefer-ip-address:truehostname:localhost metadataMap:zone:honghuZone User: ${security.user.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-timer-in-ms:60000# Service Certification security:basic:enabled:trueUser:name:honghu Password:123456management:security:enabled:false</code>
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 technical support for complete projects 1791743380
Spring Cloud Cloud Service Architecture-Commonservice-eureka Project Process Building