一、运行txlcn-tm
1、下载地址
https://gitee.com/devojiang/tx-lcn/tree/5.0.2.RELEASE/
2、导入到IDEA
3、在配置文件application.properties里
修改mysql数据库密码
4、资源文件下tx-manager.sql
mysql数据库
5、安装Redis3.2
6、运行txlcn-tm
默认密码是codingapi,支持修改(通常改配置文件即可),主要修改application.properties,添加如下内容,即可实现自定义:
tx-lcn.manager.admin-key=tx-lcn-test
二、在springcloud中的使用
1、添加依赖
<dependency>
<groupId>com.codingapi.txlcn</groupId>
<artifactId>txlcn-tc</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
<dependency>
<groupId>com.codingapi.txlcn</groupId>
<artifactId>txlcn-txmsg-netty</artifactId>
<version>5.0.2.RELEASE</version>
</dependency>
2、application.yml中配置
tx-lcn:
client:
manager-address: 127.0.0.1:8070
logger:
enabled: true
driver-class-name: com.mysql.cj.jdbc.Driver
jdbc-url: jdbc:mysql://127.0.0.1:3306/tx-manager?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai&useSSL=false
username: root
password: 1234
3、启动添加
@EnableDistributedTransaction
4、mapper中添加
@LcnTransaction
@Transactional