1 / 30
文档名称:

微服务开发手册.docx

格式:docx   大小:38KB   页数:30页
下载后只包含 1 个 DOCX 格式的文档,没有任何的图纸或源代码,查看文件列表

如果您已付费下载过本站文档,您可以点这里二次下载

分享

预览

微服务开发手册.docx

上传人:爱的奉献 2022/1/20 文件大小:38 KB

下载得到文件列表

微服务开发手册.docx

文档介绍

文档介绍:微服务开发手册
微服务开发手册
1 / 301
微服务开发手册







1.开发说明

全部服务均鉴于springboot框架开发。Springboot内嵌7
微服务开发手册
POST/users
创立一
个用户
PUT/users/ID
{"code":"1","message":"
创立用户成功
更新某
微服务开发手册
微服务开发手册
27 / 2727
微服务开发手册
","prompt":"","path":"","result":{}}
用户信

PATCH
{"code":"1","message":"


成功
更新某
/users/ID
","prompt":"","path":"","result":{}}
用户指
定字段
微服务开发手册
微服务开发手册
13 / 3013
微服务开发手册
DELETE
{"code":"1","message":"
删除
成功
删除指
/users/ID
","prompt":"","path":"","result":{}}
定用户
而关于登录、登出操作,能够理解为登录是创立
token,登出是删除
token,所以能够用
POST和DELETE来定义这两种接口。刷新
token是更新操作所以用
PUT。
3.配置文件管理
全部服务的配置文档均保留于 gitlab上,并经过配置服务 config-service来获得配置。每
个服务在 gitlab均保留一份以服务 id命名的properties文件。
在spring-boot-demo .properties 中往常配置该服务的启动端口、数据库连结参数等
信息。 当该文件有更新并 push到gitlab 后,配置服务会自动通知客户端服务更新配置信
息。
重点配置:
在主程序中需要接见配置文件的类名上加上讲解: ***@RefreshScope ,假如没有该讲解,
配置服务将不可以主动通知客户端服务更新配置。 以下:
***@RefreshScope
***@RestController
publicclassMessageRestController{
***@Value("${message:Hellodefault}")
privateStringmessage;
***@RequestMapping("/message")
StringgetMessage(){
;
}
}
当文件里的message变量发生变化后,恳求/message时返回的
message值将是更新后的 message内容。
重点依靠项:
微服务开发手册
微服务开发手册
14 / 3014
微服务开发手册
<dependency>
微服务开发手册
微服务开发手册
15 / 3015
微服务开发手册
<artifactId>spring-cloud-config-client</artifactId>
</dependency>
<dependency>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
同时需要引入 springcloud 的依靠项
<dependencyManagement>
<dependencies>
<dependency>
<artifactId>spring-cloud-dependencies</artifactId>
<version></version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
在src/main/resouce 目录成立 文件,设置配置服务 url 与service
id。
文件内容:
#配置服务地点
#servicename
spring-boot-demo
微服务开发手册
微服务开发手册
16 / 3016
微服务开发手册

url,

微服务开发手册
微服务开发手册
27 / 2727
微服务开发手册
的启动优先级最低,不可以在程序启动以前