Spring Cloud云服务架构 - commonservice-eureka 项目过程构建

简介: Spring Cloud云服务架构 - commonservice-eureka 项目过程构建 创建一个名为particle-common-eureka的maven项目,继承particle-commonservice,具体的pom.

我们针对于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文件
<code class="language-html"># 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  </code>  
  1. 增加项目的log机制和打包运行机制(后面我们会详细编写针对于Linux Centos下的打包部署机制)
  2. 自此整个项目部署完成,通过手动方式进行Run As --> Spring Boot App,运行结果如下:

控制台运行结果:

image

访问控制台并登陆:

image

控制台运行效果:

image

image

目录
相关文章
|
2月前
|
弹性计算 运维 监控
阿里云云服务诊断工具:合作伙伴架构师的深度洞察与优化建议
作为阿里云的合作伙伴架构师,我深入体验了其云服务诊断工具,该工具通过实时监控与历史趋势分析,自动化检查并提供详细的诊断报告,极大提升了运维效率和系统稳定性,特别在处理ECS实例资源不可用等问题时表现突出。此外,它支持预防性维护,帮助识别潜在问题,减少业务中断。尽管如此,仍建议增强诊断效能、扩大云产品覆盖范围、提供自定义诊断选项、加强教育与培训资源、集成第三方工具,以进一步提升用户体验。
744 243
|
2月前
|
Java 开发者 微服务
从单体到微服务:如何借助 Spring Cloud 实现架构转型
**Spring Cloud** 是一套基于 Spring 框架的**微服务架构解决方案**,它提供了一系列的工具和组件,帮助开发者快速构建分布式系统,尤其是微服务架构。
300 69
从单体到微服务:如何借助 Spring Cloud 实现架构转型
|
7天前
|
网络协议 Java Shell
java spring 项目若依框架启动失败,启动不了服务提示端口8080占用escription: Web server failed to start. Port 8080 was already in use. Action: Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port-优雅草卓伊凡解决方案
java spring 项目若依框架启动失败,启动不了服务提示端口8080占用escription: Web server failed to start. Port 8080 was already in use. Action: Identify and stop the process that’s listening on port 8080 or configure this application to listen on another port-优雅草卓伊凡解决方案
37 7
|
20天前
|
XML Java 开发者
Spring底层架构核心概念解析
理解 Spring 框架的核心概念对于开发和维护 Spring 应用程序至关重要。IOC 和 AOP 是其两个关键特性,通过依赖注入和面向切面编程实现了高效的模块化和松耦合设计。Spring 容器管理着 Beans 的生命周期和配置,而核心模块为各种应用场景提供了丰富的功能支持。通过全面掌握这些核心概念,开发者可以更加高效地利用 Spring 框架开发企业级应用。
70 18
|
2月前
|
存储 JavaScript 开发工具
基于HarmonyOS 5.0(NEXT)与SpringCloud架构的跨平台应用开发与服务集成研究【实战】
本次的.HarmonyOS Next ,ArkTS语言,HarmonyOS的元服务和DevEco Studio 开发工具,为开发者提供了构建现代化、轻量化、高性能应用的便捷方式。这些技术和工具将帮助开发者更好地适应未来的智能设备和服务提供方式。
75 8
基于HarmonyOS 5.0(NEXT)与SpringCloud架构的跨平台应用开发与服务集成研究【实战】
|
1月前
|
搜索推荐 NoSQL Java
微服务架构设计与实践:用Spring Cloud实现抖音的推荐系统
本文基于Spring Cloud实现了一个简化的抖音推荐系统,涵盖用户行为管理、视频资源管理、个性化推荐和实时数据处理四大核心功能。通过Eureka进行服务注册与发现,使用Feign实现服务间调用,并借助Redis缓存用户画像,Kafka传递用户行为数据。文章详细介绍了项目搭建、服务创建及配置过程,包括用户服务、视频服务、推荐服务和数据处理服务的开发步骤。最后,通过业务测试验证了系统的功能,并引入Resilience4j实现服务降级,确保系统在部分服务故障时仍能正常运行。此示例旨在帮助读者理解微服务架构的设计思路与实践方法。
101 17
|
9天前
|
传感器 监控 安全
智慧工地云平台的技术架构解析:微服务+Spring Cloud如何支撑海量数据?
慧工地解决方案依托AI、物联网和BIM技术,实现对施工现场的全方位、立体化管理。通过规范施工、减少安全隐患、节省人力、降低运营成本,提升工地管理的安全性、效率和精益度。该方案适用于大型建筑、基础设施、房地产开发等场景,具备微服务架构、大数据与AI分析、物联网设备联网、多端协同等创新点,推动建筑行业向数字化、智能化转型。未来将融合5G、区块链等技术,助力智慧城市建设。
|
1月前
|
监控 JavaScript 数据可视化
建筑施工一体化信息管理平台源码,支持微服务架构,采用Java、Spring Cloud、Vue等技术开发。
智慧工地云平台是专为建筑施工领域打造的一体化信息管理平台,利用大数据、云计算、物联网等技术,实现施工区域各系统数据汇总与可视化管理。平台涵盖人员、设备、物料、环境等关键因素的实时监控与数据分析,提供远程指挥、决策支持等功能,提升工作效率,促进产业信息化发展。系统由PC端、APP移动端及项目、监管、数据屏三大平台组成,支持微服务架构,采用Java、Spring Cloud、Vue等技术开发。
|
2月前
|
存储 JSON 前端开发
【Spring项目】表白墙,留言板项目的实现
本文主要介绍了表白墙项目的实现,包含前端和后端代码,以及测试
|
2月前
|
JSON 前端开发 Java

热门文章

最新文章