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

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

HongHu Cloud Eureka项目构建详解

创建一个名为particle-common-eureka的Maven项目,继承particle-commonservice,具体的POM.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

在启动类入口引用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@SpringBootApplicationpublic class ServiceApplication {    public static void main(String[] args) {        SpringApplication.run(ServiceApplication.class, args);    }}

配置application.yml文件:

# server (eureka 默认端口为:8761)server:    port: 8761# springspring:    application:        name: particle-commonservice-erueka# eurekaeureka:    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,即是60seviction-interval-timer-in-ms: 60000# 服务认证security:    basic:        enabled: true    user:        name: honghu        password: 123456management:    security:        enabled: false

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

自此整个项目部署完成,通过手动方式进行Run As --> Spring Boot App,运行结果如下:

控制台运行结果:访问控制台并登陆:控制台运行效果:

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

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

你可能感兴趣的文章
SpringBoot中集成海康威视SDK实现布防报警数据上传/交通违章图片上传并在linux上部署(附示例代码资源)
查看>>
POSIX标准和XSI扩展
查看>>
post install error,please remove node_moules before retry
查看>>
PostGIS中获取所有EPSG的编码以及对应Proj4字符串
查看>>
PostGIS在Windows上的下载与安装
查看>>
postgis数据库优化_postgresql 性能优化
查看>>
Postgres Docker版本安装mysql_fdw 插件
查看>>
Postgres invalid command \N数据恢复处理
查看>>
Postgres like 模糊查询匹配集合
查看>>
Postgres 自定义函数内实现 in 操作符的递归查询
查看>>
Postgres 返回当前时间前后指定天数的集合
查看>>
postgres--vacuum
查看>>
postgres--wal
查看>>
postgres--流复制
查看>>
postgres10配置huge_pages
查看>>
PostgreSQL 10.0 preview 变化 - pg_xlog,pg_clog,pg_log目录更名为pg_wal,pg_xact,log
查看>>
PostgreSQL 10.1 手册_部分 II. SQL 语言_第 15章 并行查询_15.2. 何时会用到并行查询?...
查看>>
PostgreSQL 10.1 手册_部分 II. SQL 语言_第 9 章 函数和操作符_9.23. 行和数组比较
查看>>
PostgreSQL 10.1 手册_部分 III. 服务器管理_第 21 章 数据库角色
查看>>
Postgresql 12.9如何配置允许远程连接
查看>>