>--------------------------------------Miroservices 9 Features
1.服务组件化(Service Componentization)
关键词独立更换和独立升级。like cpu,memory in computer.single and not influence the other component.
2.按照业务划分团队(Divide teams by business)
Divide teams by technology,like developers,testers,operations.But the miroservices is not similar,it divides by business.Just like a small teams on big teams.The best choice is dividing by business lines.
3.做产品的态度(Product attitude)
it is a product,not a project.it has to be reliable.
4.智能端点和哑管道(Smart endpoints and dumb pipes)
In traditional project that messages with each other through rpc ,and then it produces more communication.The system will have bad performance.Therefor we need coarse-grained communication.for example http,restful api or rabbit mq message middleware.
5.去中心化处理(Decentralization)
6.去中心化管理数据(Decentralization manage datebase)
分布式数据存储难度较高,因此我们提倡非事务性的调用。
7.基础设施自动化
自动化部署,自动化测试。
automated deploymeng,automated testing
8.容错设计(Fault-tolerant design)
9.演进式设计
>>--------------------------------------Spring Boot
1、You need to write some test classes,你需要写一些测试类,在微服务系统中测试类相当重要。
@RunWit(SpringJunit4ClassRunner.class) 引入Spring对于junit4的支持
@SpringApplicationConfiguration(classes=your start class) 指定Springboot的启动类
@WebAppConfiguration 开始web应用的配置,用于模拟ServeletContext
@Before 执行在@Test之前的任务
MockMvc
mvc的perform函数执行一次请求调用,accept用于接受参数,andExpect用来测试返回值
2、SpringBoot的配置文件
拥有properties和yaml的两种方式
3.自定义参数的赋值,@Value的两种形式
1.利用PlaceHolder方式,格式为${key}
2.利用Spring Expression Language,格式为#{key}
4.部署多个环境需要的命令
如果你需要部署多个环境,那么你需要在配置文件中设置如下格式:application-{profile}.properties
application-dev.properties 开发环境
application-test.properties 测试环境
application-prod.properties 生产环境
如果你需要加载对应的配置文件,你需要application.profies.active=test就会加载测试环境配置,主要使用于maven中,如果需要加深学习请了解相关知识。
>>>--------------------------------------Spring-Boot-starter-actuator
1.监控端点分为三大类
应用配置类
获取应用程序中的配置信息,环境变量,自动化配置报告
度量指标类
用来度量的类,例如内存大小,线程池大小,http请求统计
操作控制类
对应用的关系等操作类实现
2./autoconfig,自动化配置信息
positiveMatches 返回的条件是匹配成功的自动化配置
negativeMatches返回的是条件匹配不成功的自动化配置
/beans
该端点获取上下文中创建的所有的bean
/configprops
应用中配置的属性信息报告,prefix代表了属性的前缀,properties代表的属性的值
/env
与configprops不同,它用来获取所有可用的环境的属性报告,包括环境变量,jvm,应用的配置属性,命令行中的参数。
/mapping
映射和controller
/info
返回自定义的属性信息
/metrics
返回各类重要的度量指标,例如内存信息,线程信息,垃圾回收信息等。
/health
可以实现自带的health接口达到监控的目的,监控一些springcloud还未封装的产品的状态,实现接口为HealthIndicator
/dump
暴露运行中线程的信息,使用的ThreadMXBean的dumpAllThreads返回含有同步信息的活动线程详情
/trace
追踪返回http信息状态
/shutdown
用来关闭的端点,需要在配种中开启
endpoints.shutdown.enable=true