博客
关于我
(八)整合spring cloud云服务架构 - commonservice-eureka 项目构建过程
阅读量:131 次
发布时间:2019-02-27

本文共 3429 字,大约阅读时间需要 11 分钟。

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

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

Xml代码 收藏代码

4.0.0
com.ml.honghu
particle-commonservice
0.0.1-SNAPSHOT
particle-commonservice-eureka
jar
particle-commonservice-eureka
particle-commonservice project for Spring Boot
org.springframework.cloud
spring-cloud-starter-eureka-server
org.springframework.boot
spring-boot-starter-security
org.springframework.boot
spring-boot-devtools
org.springframework.boot
spring-boot-starter-test
test
org.springframework.boot
spring-boot-maven-plugin
1
repackage
2
build-info
true
  1. 在启动类入口引用eureka的相关配置,代码如下:

Java代码 收藏代码

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文件

Xml代码 收藏代码

# 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,运行结果如下:

控制台运行结果:

在这里插入图片描述

访问控制台并登陆:
在这里插入图片描述
控制台运行效果:
在这里插入图片描述
在这里插入图片描述

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

转载地址:http://fvef.baihongyu.com/

你可能感兴趣的文章
mysqldump的一些用法
查看>>
mysqli
查看>>
MySQLIntegrityConstraintViolationException异常处理
查看>>
mysqlreport分析工具详解
查看>>
MySQLSyntaxErrorException: Unknown error 1146和SQLSyntaxErrorException: Unknown error 1146
查看>>
Mysql_Postgresql中_geometry数据操作_st_astext_GeomFromEWKT函数_在java中转换geometry的16进制数据---PostgreSQL工作笔记007
查看>>
mysql_real_connect 参数注意
查看>>
mysql_secure_installation初始化数据库报Access denied
查看>>
MySQL_西安11月销售昨日未上架的产品_20161212
查看>>
Mysql——深入浅出InnoDB底层原理
查看>>
MySQL“被动”性能优化汇总
查看>>
MySQL、HBase 和 Elasticsearch:特点与区别详解
查看>>
MySQL、Redis高频面试题汇总
查看>>
MYSQL、SQL Server、Oracle数据库排序空值null问题及其解决办法
查看>>
mysql一个字段为空时使用另一个字段排序
查看>>
MySQL一个表A中多个字段关联了表B的ID,如何关联查询?
查看>>
MYSQL一直显示正在启动
查看>>
MySQL一站到底!华为首发MySQL进阶宝典,基础+优化+源码+架构+实战五飞
查看>>
MySQL万字总结!超详细!
查看>>
Mysql下载以及安装(新手入门,超详细)
查看>>