(八)Java B2B2C多用户商城 springcloud架构- commonservice-eureka 项目构建过程

news/2024/5/19 18:55:13

我们针对于HongHu cloud的eureka项目做以下构建,整个构建的过程很简单,我会将每一步都构建过程记录下来,希望可以帮助到大家:

  1. 创建一个名为particle-common-eureka的maven项目,继承particle-commonservice,具体的pom.xml配置文件如下:
<?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>  
  1. 在启动类入口引用eureka的相关配置,代码如下:
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);  
    }  
}  
  1. 配置application.yml文件
# server (eureka 默认端口为:8761)  
server:  
  port: 8761  
# spring  
spring:  
  application:  
    name: particle-commonservice-erueka  
# eureka  
eureka:   
  client:   
    # 是否注册到eureka  
    register-with-eureka: true  
    # 是否从eureka获取注册信息  
    fetch-registry: false  
    availability-zones:   
      honghu: honghuZone  
    service-url:   
      honghuZone: http://honghu:123456@localhost:8761/eureka/  
      defaultZone: http://honghu:123456@localhost:8761/eureka/  
  instance:  
    prefer-ip-address: true  
    hostname: localhost  
    metadataMap:  
      zone: honghuZone  
      user: ${security.user.name}  
      password: {security.user.password}  
  # 指定环境  
  environment: dev  
  #指定数据中心  
  datacenter: honghu  
  # 关闭自我保护模式  
  server:   
    enable-self-preservation: false  
  #设置清理无效节点的时间间隔,默认60000,即是60s  
    eviction-interval-timer-in-ms: 60000  
# 服务认证  
security:   
  basic:   
    enabled: true  
  user:   
    name: honghu  
    password: 123456  
management:  
  security:  
    enabled: false
  1. 增加项目的log机制和打包运行机制(后面我们会详细编写针对于Linux Centos下的打包部署机制)
  2. 自此整个项目部署完成,通过手动方式进行Run As --> Spring Boot App,运行结果如下:

控制台运行结果:

clipboard.png

访问控制台并登陆:

clipboard.png

控制台运行效果:

clipboard.png

clipboard.png

从现在开始,我这边会将近期研发的spring cloud微服务云架构的搭建过程和精髓记录下来,帮助更多有兴趣研发spring cloud框架的朋友,大家来一起探讨spring cloud架构的搭建过程及如何运用于企业项目。Spring Cloud大型企业分布式微服务云构建的B2B2C电子商务平台源码请加企鹅求求: 一零叁八七七四六贰六


http://www.niftyadmin.cn/n/2246217.html

相关文章

【评分卡】评分卡入门与创建原则——分箱、WOE、IV、分值分配

本文主要讲“变量选择”“模型开发”“评分卡创建和刻度” 变量分析 首先&#xff0c;需要确定变量之间是否存在共线性&#xff0c;若存在高度相关性&#xff0c;只需保存最稳定、预测能力最高的那个。需要通过 VIF(variance inflation factor&#xff09;也就是 方差膨胀因子…

CF-631-.Interview-水题

A.Interview Time Limit:1000MS Memory Limit:262144KB 64bit IO Format:%I64d & %I64u Submit Status Practice CodeForces 631A Description Blake is a CEO of a large company called “Blake Technologies”. He loves his company very much and he thinks th…

ntp多台主机时间同步

通俗的讲&#xff0c;多台主机ntp时间同步&#xff0c;就是自定义集群中一台机器&#xff08;我们这里叫它server&#xff09;与网络时间同步&#xff0c;然后其它主机与server主机时间同步 另外&#xff0c;ntp时间同步机制不是我们想象的那样直接同步&#xff0c;而是“逐渐”…

5G已来,5G精品系列课免费送?

5G不再只是从2G.txt到3G.jpg再到4G.avi的网络速率的提升&#xff0c;而是将人与人之间的通信扩展到万物互联&#xff0c;打造全移动和全连接的数字化社会。 众所周知&#xff0c;2018年6月中旬&#xff0c;3GPP全会批准通过了5G NR独立组网(SA)规范标准。全球各电信厂商和运营商…

Java大数简单题---Yet another A + B

PracticeGym 100735I Description Statements You are given three numbers. Is there a way to replace variables A, B and C with these numbers so the equality A  B  C is correct? Input There are three numbers X1, X2 and X3 (1 ≤ Xi ≤ 10100), each…

Cisco HyperFlex 多区域上联(Disjoint Networks Upstream)

Cisco HyperFlex 多区域上联&#xff08;Disjoint Networks Upstream&#xff09;Deploy Layer 2 Disjoint Networks Upstream in End Host Mode for HyperFlex一般意义上的HX平台是部署在大二层环境中&#xff0c;不同vlan跑不同的功能&#xff08;data&#xff0c;mgt&#x…

Restore 数学题,水题(转)

C - Restore Time Limit:25000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practice Gym 100735E Description standard input/output Statements Given a matrix A of size N * N. The rows are numbered from 0 to N-1, the column…

unity实战 手机屏幕适配

使用背景 为了在UI中使用特效层&#xff0c;项目Canvas采用了Screen Space-Camera类型 UI的Scale Mode 选择的是Scale With Screen Size 的Expand&#xff0c;画布大小填的是1334, 750 在该选择下&#xff0c;会自动根据分辨率适配宽度/高度。 自动适配的规则是&#xff1a; 屏…