博客
关于我
(八)整合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/

你可能感兴趣的文章
Python3之打印操作打印流重定向(下)
查看>>
python3判断字典、列表、元组为空以及字典是否存在某个key的方法
查看>>
Python3利用pymysql操作 MySQL
查看>>
python3处理json文件中含有中文dumps的应用
查看>>
Python3子进程输出
查看>>
Python3学习笔记3,变量、运算符
查看>>
Python3学习笔记(urllib模块的使用)
查看>>
python3安装scapy_Linux下安装scapy-python3
查看>>
python3实现socket通信
查看>>
Python关于numpy.transpose函数详细解析附代码
查看>>
Python3导入自定义模块的3种方式
查看>>
python3打开txt文件_使用Python 3从文本文件读取句子并添加到列表中
查看>>
python3爬虫抓取智联招聘职位信息代码
查看>>
Python3爬虫数据入数据库---把爬取到的数据存到数据库,带数据库去重功能
查看>>
python3的 pymysql把mysqldb库取代了,让python 3支持mysqldb的解决方法
查看>>
Python3笔记——IDE的选择
查看>>
python3简单使用requests 用户代理,cookie池
查看>>
Python3组播通信编程实现教程(发送者+接收者)
查看>>
Python3编写网络爬虫10-数据存储方式三-CSV文件存储
查看>>
python3读取redis返回数据带有'b'的问题
查看>>