ITPub博客

首页 > IT职业 > IT生活 > spring cloud云服务架构 - HongHu commonse

spring cloud云服务架构 - HongHu commonse

IT生活 作者:nighteagle 时间:2021-09-09 09:25:33 0 删除 编辑

上一篇我们回顾了关于 spring cloud eureka的相关基础知识,现在我们针对于HongHu cloud的eureka项目做以下构建,整个构建的过程很简单,我会将每一步都构建过程记录下来,希望可以帮助到大家:

1. 创建一个名为particle-common-eureka的maven项目,继承particle-commonservice,具体的pom.xml配置文件如下:

4.0.0com.ml.honghuparticle-commonservice0.0.1-SNAPSHOTparticle-commonservice-eurekajarparticle-commonservice-eurekaparticle-commonservice project for Spring Bootorg.springframework.cloudspring-cloud-starter-eureka-serverorg.springframework.bootspring-boot-starter-securityorg.springframework.bootspring-boot-devtoolsorg.springframework.bootspring-boot-starter-testtestorg.springframework.bootspring-boot-maven-plugin1repackage
               
               2
                   
                       build-info
                   
               true

2. 在启动类入口引用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);
}
}

3. 配置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

4. 增加项目的log机制和打包运行机制(后面我们会详细编写针对于Linux Centos下的打包部署机制)

5. 自此整个项目部署完成

从现在开始,我这边会将近期研发的spring cloud微服务云架构的搭建过程和精髓记录下来,帮助更多有兴趣研发spring cloud框架的朋友,大家来一起探讨spring cloud架构的搭建过程及如何运用于企业项目。


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/4363/viewspace-2802868/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2019-08-12

  • 博文量
    97
  • 访问量
    744