内容简介:mica(云母) mica 云母,寓意为云服务的核心,增强 Spring cloud 功能,使得 Spring cloud 服务开发更加方便快捷。 mica 核心依赖 mica 基于 java 8,没有历史包袱,支持传统 Servlet 和 Reactive(webflux)。采...
mica(云母)
mica 云母,寓意为云服务的核心,增强 Spring cloud 功能,使得 Spring cloud 服务开发更加方便快捷。
mica 核心依赖
mica 基于 java 8,没有历史包袱,支持传统 Servlet 和 Reactive(webflux)。采用 mica-auto 自动生成 spring.factories 和 spring-devtools.properties 配置,仅依赖 Spring boot、Spring cloud 全家桶,无第三方依赖。市面上鲜有的微服务核心组件。
| 依赖 | 版本 |
| Spring | 5.x |
| Spring Boot | 2.1.x |
| Spring Cloud | Greenwich 版 |
更新说明
- ✨ 完善
mica-plus-redis添加MicaRedisCacheBean,使用同redis命令. - ✨
redis序列化方式可配置化. - ✨ 提高 webflux 的日志和
ReactiveRequestContextFilter排序,方便在 spring cloud gateway 中使用. - ✨ 调整验证码 base64,加上 base64 图片前缀.
- ✨
DigestUtil对Md5、Sha、Hmac等系列签名算法添加非 hex 方法. - ???? bean copy Convert 注解支持问题.
- ➕ 添加新组件
mica-http. - ➕ 添加新组件
mica-social. - ➕ 添加新组件
mica-plus-social. - ➕ 添加新组件
mica-plus-ribbon. - ⬆️ 升级
Spring boot版本到2.1.6.RELEASE. - ⬆️ 升级
Spring cloud版本到Greenwich.SR1. - ⬆️ 升级
swagger-bootstrap-ui到1.9.4.
mica-http 更加简单易用的 http 工具包
mica-http 是 okhttp 的封装,Fluent 语法的 http 工具包,语法参考 HttpClient Fluent API。
示例代码
private String getUserEmail(String accessToken) {
return HttpRequest.get("https://api.linkedin.com/v2/emailAddress?q=members&projection=(elements*(handle~))")
.addHeader("Host", "api.linkedin.com")
.addHeader("Connection", "Keep-Alive")
.addHeader("Authorization", "Bearer " + accessToken)
.log()
.execute()
.asJsonNode()
.at("/elements/0/handle~0/emailAddress")
.asText();
}
public static void logBasic() {
HttpRequest.post("https://www.baidu.com/do-stuff")
.log(HttpLoggingInterceptor.Level.BASIC)
.formBuilder()
.add("a", "b")
.execute()
.asBytes();
}
调试日志
可以使用 .log() 方法输出请求详情。
19:50:27.223 [main] INFO net.dreamlu.http.Slf4jLogger - --> GET https://graph.qq.com/oauth2.0/token?code=code&client_id=clientId&client_secret=clientSecret&grant_type=authorization_code&redirect_uri=redirectUri http/1.1
19:50:27.228 [main] INFO net.dreamlu.http.Slf4jLogger - User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36
19:50:27.228 [main] INFO net.dreamlu.http.Slf4jLogger - --> END GET
19:50:27.663 [main] INFO net.dreamlu.http.Slf4jLogger - <-- 200 OK https://graph.qq.com/oauth2.0/token?code=code&client_id=clientId&client_secret=clientSecret&grant_type=authorization_code&redirect_uri=redirectUri (434ms)
19:50:27.664 [main] INFO net.dreamlu.http.Slf4jLogger - Server: nginx
19:50:27.666 [main] INFO net.dreamlu.http.Slf4jLogger - Date: Sun, 23 Jun 2019 11:50:27 GMT
19:50:27.666 [main] INFO net.dreamlu.http.Slf4jLogger - Content-Type: text/html
19:50:27.667 [main] INFO net.dreamlu.http.Slf4jLogger - Content-Length: 86
19:50:27.667 [main] INFO net.dreamlu.http.Slf4jLogger - Connection: keep-alive
19:50:27.667 [main] INFO net.dreamlu.http.Slf4jLogger - Keep-Alive: timeout=50
19:50:27.668 [main] INFO net.dreamlu.http.Slf4jLogger - Cache-Control: no-cache
19:50:27.670 [main] INFO net.dreamlu.http.Slf4jLogger -
19:50:27.671 [main] INFO net.dreamlu.http.Slf4jLogger - callback( {"error":100001,"error_description":"param client_id is wrong or lost "} );
19:50:27.671 [main] INFO net.dreamlu.http.Slf4jLogger - <-- END HTTP (86-byte body)
mica-plus-social 第三方登录组件 SDK
目前支持 gitee、开源中国、qq、微信、微博、钉钉、百度、google、Facebook、Linkedin 等十多个服务。
配置
mica:
social:
qq:
client-id: xxxxxx
client-secret: xxxxx
redirect-uri: http://www.dreamlu.net/api/qq/callback
构造授权地址
@Autowired
private AuthQqRequest authRequest;
@GetMapping("auth/qq")
public String auth() {
return "redirect:" + authRequest.authorize();
}
@GetMapping("callback/qq")
public String callback(String code) {
AuthResponse authResponse = authRequest.login(code);
// 业务代码
}
mica-plus-ribbon 自定义 ribbon 规则方便开发
功能
- 【优先级最高】ip 相同的服务(方便本地多服务联调)。
- 可设置选择的 ip 或者 ip 段,例如:
172.21.0.*、172.21.0.8*。 - 可设定 tag,为了以后版本发布(灰度)做基础,可能还需要扩展。
配置项
前缀:mica.ribbon.rule
| 配置项 | 默认值 | 说明 |
| enabled | true | 是否启用 |
| prior-ip-pattern | 空 | 优先的 ip 列表,支持通配符,例如:172.21.0.81、172.21.0.8、172.21.0. |
| tag | 无 | 服务的 tag,用于灰度,匹配:nacos.discovery.metadata.tag |
配置示例
例如:dev
mica:
ribbon:
rule:
prior-ip-pattern:
- 172.21.0.*
文档
- 文档地址(官网):https://www.dreamlu.net/#/doc/docs
- 文档地址(语雀-可关注订阅):https://www.yuque.com/dreamlu/mica
- 示例项目:https://github.com/lets-mica/mica-example
以上所述就是小编给大家介绍的《Spring Cloud 微服务组件 mica v1.1.3 发布,新增 http和第三方登录组件》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!
猜你喜欢:- 第三方组件上线的最佳实践
- JustAuth 关注破 10k,第三方登录开源组件
- Spring Cloud 微服务组件 mica v1.1.3 发布,新增 http和第三方登录组件
- vue移动端引用第三方组件-lytab(学习笔记)
- Angular中修改第三方组件的样式 - zorro日期选择器右端不对齐的BUG
- ybg-spring-fast 添加码云第三方登录,微信第三方登录
本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们。
Docker——容器与容器云(第2版)
浙江大学SEL实验室 / 人民邮电出版社 / 2016-10 / 89.00元
本书根据Docker 1.10版和Kubernetes 1.2版对第1版进行了全面更新,从实践者的角度出发,以Docker和Kubernetes为重点,沿着“基本用法介绍”到“核心原理解读”到“高级实践技巧”的思路,一本书讲透当前主流的容器和容器云技术,有助于读者在实际场景中利用Docker容器和容器云解决问题并启发新的思考。全书包括两部分,第一部分深入解读Docker容器技术,包括Docker架......一起来看看 《Docker——容器与容器云(第2版)》 这本书的介绍吧!