Integration of spring cloud cloud service architecture - HongHu commonservice-eureka project construction process

Now we build the following for the eureka project of HongHu cloud. The whole process of building is very simple. I will record every step of the process. I hope it can help you:

1. Create a maven project named particle-common-eureka and inherit particle-commonservice. 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</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. Refer to the configuration of eureka at the startup class entry. 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);
	}
}

3. Configure the application.yml file

 server (default port: 8761) server: port: 8761 spring: application: name: particle-commonservice-erueka eureka: client: 
    # Register to Eureka register-with-eureka: true
    123456@localhost:8761/eureka/ defaultZone: http://honghu:123456@localhost:8761/eureka/ defaultZone: http://honghu:123456@localhost:8761/eureka/ defaultZone: @localhost:8761/eureka/ preferred-address: hostname: true Zone: honghuZone; user: ${security. user. name} password: {security. user. password}      
   Designated environment: dev  Designated data center: Honghu  Closed self-protection mode server: enable-self-preservation: false
  # Set the time interval for cleaning up invalid nodes by default of 60000, that is 60s eviction-interval-timer-in-ms: 60000 service authentication security: basic: enabled: true user: name: Honghu password: 123456 management: security: enabled: false

4. Increase the project's log mechanism and package operation mechanism (we will write the package deployment mechanism for Linux Centos in detail later)

5. Since then, the whole project has been deployed and Run As - > Spring Boot App has been manually implemented. The results are as follows:

Console operation results:

Access the console and log in:

Console operation effect:

From now on, I will record the construction process and essence of the spring cloud micro-service Cloud Architecture recently developed, and help more friends who are interested in developing the spring cloud framework, hoping to help more good scholars. Let's discuss the process of building spring cloud architecture and how to apply it to industry projects. Source Source

Tags: Java Spring Maven xml Apache

Posted on Wed, 19 Dec 2018 22:18:05 -0800 by FarhanKhalaf