@TOC
問題背景
從零開始學springcloud微服務項目
注意事項:
- 約定 > 配置 > 編碼
- IDEA版本2021.1
- 這個項目,我分了很多篇章婴噩,每篇文章一個操作步驟擎场,目的是顯得更簡單明了
- controller調service,service調dao
- 默認安裝nginx
- 項目源碼以及sentinel安裝包
Seata處理分布式事務
1 Seata中文文檔:https://seata.io/zh-cn/docs/overview/what-is-seata.html
2 下載地址:https://github.com/seata/seata/releases/tag/v1.4.2
sql腳本下載地址:https://seata.io/zh-cn/blog/download.html
3 修改file.conf几莽,更改存儲模式和nacos的賬號密碼迅办,mysql8以上驅動加cj
mode = "db"
## database store property
db {
## the implement of javax.sql.DataSource, such as DruidDataSource(druid)/BasicDataSource(dbcp)/HikariDataSource(hikari) etc.
datasource = "druid"
## mysql/oracle/postgresql/h2/oceanbase etc.
dbType = "mysql"
driverClassName = "com.mysql.cj.jdbc.Driver"
## if using mysql to store the data, recommend add rewriteBatchedStatements=true in jdbc connection param
url = "jdbc:mysql://127.0.0.1:3306/seata?rewriteBatchedStatements=true"
user = "root"
password = "123456"
minConn = 5
maxConn = 100
globalTable = "global_table"
branchTable = "branch_table"
lockTable = "lock_table"
queryLimit = 100
maxWait = 5000
}
4 修改registry.conf,更改注冊中心和配置中心類型
type = "nacos"
registry {
# file 章蚣、nacos 站欺、eureka、redis纤垂、zk矾策、consul、etcd3峭沦、sofa
type = "nacos"
nacos {
application = "seata-server"
serverAddr = "127.0.0.1:8848"
group = "SEATA_GROUP"
namespace = "seata"
cluster = "default"
username = ""
password = ""
}
}
config {
# file贾虽、nacos 、apollo吼鱼、zk蓬豁、consul绰咽、etcd3
type = "nacos"
nacos {
serverAddr = "127.0.0.1:8848"
namespace = "seata"
group = "SEATA_GROUP"
username = ""
password = ""
dataId = "seataServer.properties"
}
}
5 Linux啟動方式
sh ./bin/seata-server.sh
window啟動方式
bin\seata-server.bat
6 創(chuàng)建seata數據庫
create database seata;
7 導入sql腳本,將seata-1.4.2的script復制到seata-server-1.4.2
8 在數據庫中執(zhí)行sql文件:seata-server-1.4.2\script\server\db\mysql.sql
Seata配置文件放在Nacos
1 新建一個配置
2 填寫信息seataServer.properties SEATA_GROUP
service.vgroupMapping.mygroup=default
store.mode=db
-----db-----
store.db.datasource=druid
store.db.dbType=mysql
store.db.driverClassName=com.mysql.cj.jdbc.Driver
store.db.url=jdbc:mysql://localhost:3306/mysqltest?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai
store.db.user=root
store.db.password=123456
----client----
client.undo.logTable=undo_log
總結
- 就此springcloud告一段落
SpringCloud無介紹快使用地粪,Seata處理分布式事務(二十五)
SpringCloud無介紹快使用取募,sentinel服務熔斷功能(二十四)
SpringCloud無介紹快使用,sentinel注解@SentinelResource的基本使用(二十三)
SpringCloud無介紹快使用蟆技,sentinel熱點key限流與系統(tǒng)規(guī)則的基本使用(二十二)
SpringCloud無介紹快使用玩敏,sentinel熔斷降級和限流的基本使用(二十一)
SpringCloud無介紹快使用,Nacos集群和Nginx代理(二十)
SpringCloud無介紹快使用质礼,nacos配置中心的基本使用(十九)
SpringCloud無介紹快使用聊品,nacos注冊中心的基本使用(十八)
SpringCloud無介紹快使用,gateway通過微服務名實現動態(tài)路由(十七)
SpringCloud無介紹快使用几苍,gateway的基本使用(十六)
SpringCloud無介紹快使用,Ribbon負載均衡工具與OpenFeign的使用(十五)
SpringCloud無介紹快使用陈哑,使用Zookeeper替換Eureka服務注冊與發(fā)現(十四)
SpringCloud無介紹快使用妻坝,服務發(fā)現Discovery和Eureka自我保護(十三)
SpringCloud無介紹快使用,集群cloud-provider-payment8002搭建(十二)
SpringCloud無介紹快使用惊窖,集群Eureka服務注冊中心cloud-eureka-server7002搭建(十一)
SpringCloud無介紹快使用刽宪,單機Eureka服務注冊中心cloud-eureka-server7001搭建(十)
SpringCloud無介紹快使用,新建cloud-api-commons公共模塊module(九)
SpringCloud無介紹快使用界酒,新建子module消費者訂單模塊(八)
SpringCloud無介紹快使用圣拄,熱部署devtools配置(七)
SpringCloud無介紹快使用,子module提供者支付微服務業(yè)務開發(fā)(六)
SpringCloud無介紹快使用毁欣,新建子module提供者支付微服務yml整合和新建啟動類(五)
SpringCloud無介紹快使用庇谆,新建子module提供者支付微服務pom整合(四)
SpringCloud無介紹快使用,springcloud父工程pom文件整理(三)
SpringCloud無介紹快使用凭疮,IDEA新建springcloud父工程(二)
SpringCloud無介紹快使用饭耳,與Spingboot之間的兼容版本選擇(一)
作為程序員第 192 篇文章,每次寫一句歌詞記錄一下执解,看看人生有幾首歌的時間寞肖,wahahaha ...