# springboot-compose
**Repository Path**: yanyizzz/springboot-compose
## Basic Information
- **Project Name**: springboot-compose
- **Description**: springboot模块集成学习。WebSocket,ThreadPool
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 2
- **Created**: 2021-05-24
- **Last Updated**: 2024-11-08
## Categories & Tags
**Categories**: Uncategorized
**Tags**: test
## README
# springboot-compose
## 介绍
springboot模块集成学习。
## 模块
1. WebSocket
2. ThreadPool
3. Shiro,JWT
4. 支付宝(AliPay)
5. OkHttp
6. SpringBoot-RestTemplate
7. Dubbo
8. [Job](http://mp.weixin.qq.com/s?__biz=MzU4NjQ1NDkyNQ==&mid=2247495567&idx=2&sn=485463d3d32ed786fa7755084eeb1d1e&chksm=fdf9ad6dca8e247b5f4b4e7a5634b381ca47b320d1d47dc398e0a7961e6dbe4801063885485f&mpshare=1&scene=24&srcid=0716B96tQ5aVET21rue3P4zc&sharer_sharetime=1626406276068&sharer_shareid=f425cb5ff30b8812d10a914318ce1a28#rd)
9. [RabbitMQ](https://mp.weixin.qq.com/s/ENuO0cVpaqfgWxR8fYs9zQ)
10. [Aop](https://mp.weixin.qq.com/s/PRYxubOReCxpHQQMk3Zang)
11. [Kafka](https://blog.csdn.net/qq_34533957/article/details/108350369)
12. [Security](https://github.com/FleyX/demo-project/tree/master/springboot_spirngsecurity_demo)
## 使用说明
### 1.[WebSocket](https://mp.weixin.qq.com/s/zazMWGdLfUNRPRHelyqB6w)
1. 启动项目,开启2个http://localhost:8080/index/xxx
2. 在页面上toUserId输入相应的xxx,发送消息可以通讯
3. 通过消息回调onmessage,自定义各种操作。
### 2.[Thread Pool](https://mp.weixin.qq.com/s/eygAr3hrsDO7KVkku2dKqA)
1. 启动项目,访问http://localhost:8080/thread/async
### 3.[Shiro+JWT](https://mp.weixin.qq.com/s/8ff9tFYSrIQv8dvUeBX3Tg)
[进阶](https://blog.csdn.net/wws_p/article/details/107126321)
[代码](https://gitee.com/hyitres/wws-second-springboot-shiro-jwt)
[Spring Security](https://mp.weixin.qq.com/s/LNE6vYTnCXcTrNYekzp1Qw)
用户:root,vip,user
URL | 作用 | 参数
---|---|---
http://localhost:8080/login?account=test&password=123 | 登入 |
http://localhost:8080/index| 所有人都可以访问,但是用户与游客看到的内容不同 | Authorization:TOKEN
http://localhost:8080/auth| 登入的用户才可以进行访问 | Authorization:TOKEN
http://localhost:8080/role| admin的角色用户才可以登入 | Authorization:TOKEN
http://localhost:8080/permission| 拥有view和edit权限的用户才可以访问 | Authorization:TOKEN
### 4.AliPay
1.[开发者平台](https://open.alipay.com/platform/developerIndex.htm)
2.[在线加密](https://miniu.alipay.com/keytool/create)
3.[参考](https://github.com/OUYANGSIHAI/sihai-maven-ssm-alipay)
4.相关页面
- 1.列表页:http://localhost:8080
- 2.确认页:http://localhost:8080/product?productId=1
- 3.生成订单:http://localhost:8080/createOrder
- 4.支付页:http://localhost:8080/pay?orderId=xxx
- 5.通知:http://localhost:8080/alipayReturnNotice
### 5.OkHttp
[OkHttp4 RequestBody.create()过时解决办法](https://blog.csdn.net/qq_19306415/article/details/102954712)
单元测试:
1.获取Token
2.上传文件
3.下载文件
### 6.SpringBoot-RestTemplate
[文件下载参考](https://lequ7.com/guan-yu-spring-jing-jiang-resttemplate-di-6-pian-wen-jian-shang-chuan-xia-zai-yu-da-wen
-jian-liu-shi-xia-zai.html)
1.获取Token:http://localhost:8080/getToken
2.获取下载链接:http://localhost:8080/getBatchDownloadLink
3.下载文件:http://localhost:8080/downLoadFile
4.上传文件:http://localhost:8080/upload
大文件下载
```java
void testDownLoadBigFile() throws IOException {
// 待下载的文件地址
String url = "http://localhost:8888/2020/08/12/028b38f1-3f9b-4088-9bea-1af8c18cd619.png";
// 文件保留的本地门路
String targetPath = "D:\\data\\local\\splash-down-big.png";
//定义申请头的接管类型
RequestCallback requestCallback = request -> request.getHeaders()
.setAccept(Arrays.asList(MediaType.APPLICATION_OCTET_STREAM, MediaType.ALL));
//对响应进行流式解决而不是将其全副加载到内存中
restTemplate.execute(url, HttpMethod.GET, requestCallback, clientHttpResponse -> {
Files.copy(clientHttpResponse.getBody(), Paths.get(targetPath));
return null;
});
}
```
### 7.Dubbo
1. 基本引用
```xml
org.apache.dubbo
dubbo-spring-boot-starter
org.apache.zookeeper
zookeeper
3.4.14
org.apache.curator
curator-framework
org.apache.curator
curator-recipes
```
2. 模块
公共模块:springboot-dubbo-common
消费者:springboot-dubbo-consumer
服务者:springboot-dubbo-provider
3. 下载zookeeper和[dubbo-admin](https://github.com/apache/dubbo-admin/blob/develop/README_ZH.md)
>dubbo默认端口20881;tool目录下有打包好的dubbo-admin.jar
>http://localhost:2182/
> 账号:root
> 密码:root
```
# 下载类似bin结尾==》apache-zookeeper-3.7.0-bin.tar.gz
https://archive.apache.org/dist/zookeeper/
# 修改admin server端口:https://blog.csdn.net/weixin_34310785/article/details/91988208
admin.serverPort=2182
```
### 9.RabbitMQ
交换机
直连交换机(Direct exchange): 具有路由功能的交换机,绑定到此交换机的时候需要指定一个routing_key,交换机发送消息的时候需要routing_key,会将消息发送道对应的队列
扇形交换机(Fanout exchange): 广播消息到所有队列,没有任何处理,速度最快
主题交换机(Topic exchange): 在直连交换机基础上增加模式匹配,也就是对routing_key进行模式匹配,*代表一个单词,#代表多个单词
首部交换机(Headers exchange): 忽略routing_key,使用Headers信息(一个Hash的数据结构)进行匹配,优势在于可以有更多更灵活的匹配规则
### 11.Kafka
- [docker安装kafka和zookeeper](https://www.hangge.com/blog/cache/detail_2791.html)
- [代码](https://blog.csdn.net/qq_34533957/article/details/108350369)
- 访问
```
# 1.启动KafkaProviderApplication生产者:发送消息
http://localhost:8080/kafka/send?message=11
# 2.启动KafkaConsumerApplication消费者:接受消息
```