spring cloud microservice architecture b2b2c e-commerce - Common Service Eureka project construction process

For the eureka project of HongHu cloud, we do the following construction. The whole construction process is very simple. I will record every step of the construction process, hoping to help you:

Create a maven project named particle common Eureka, which inherits the particle common service. 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">  
    <description>particle-commonservice project for Spring Boot</description>  

2. Refer to the relevant configuration of eureka in 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;  
public class ServiceApplication {  
    public static void main(String[] args) {  
        SpringApplication.run(ServiceApplication.class, args);  

3. Configure the application.yml file

# Server (the default port of Eureka is 8761)  
  port: 8761  
# spring  
    name: particle-commonservice-erueka  
# eureka  
    # Register to eureka or not  
    register-with-eureka: true  
    # Whether to obtain registration information from eureka  
    fetch-registry: false  
      honghu: honghuZone  
      honghuZone: http://honghu:123456@localhost:8761/eureka/  
      defaultZone: http://honghu:123456@localhost:8761/eureka/  
    prefer-ip-address: true  
    hostname: localhost  
      zone: honghuZone  
      user: ${security.user.name}  
      password: {security.user.password}  
  # Designated environment  
  environment: dev  
  #Specify data center  
  datacenter: honghu  
  # Turn off self protection mode  
    enable-self-preservation: false  
  #Set the time interval for cleaning invalid nodes. The default is 60000, which is 60s  
    eviction-interval-timer-in-ms: 60000  
# Service authentication  
    enabled: true  
    name: honghu  
    password: 123456  
    enabled: false  
//Source code of e-commerce platform: 103874626

Add the log mechanism and package operation mechanism of the project (we will write the package deployment mechanism for Linux Centos in detail later)

Since then, the whole project has been deployed. Run as > spring boot app manually. The results are as follows:

Console run results:

Access the console and log in:

Console operation effect:

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

Tags: Java Spring Maven Apache xml

Posted on Wed, 06 Nov 2019 11:29:20 -0800 by Styles2304