修复seata事务问题
This commit is contained in:
@ -49,6 +49,11 @@
|
||||
<artifactId>mall-ebtp-cloud-redis-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.chinaunicom.ebtp</groupId>
|
||||
<artifactId>mall-ebtp-cloud-seata-starter</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.baomidou</groupId>
|
||||
<artifactId>mybatis-plus-generator</artifactId>
|
||||
|
@ -0,0 +1,26 @@
|
||||
package com.chinaunicom.mall.ebtp.core.config;
|
||||
|
||||
import com.chinaunicom.mall.ebtp.common.config.FeignConfig;
|
||||
import feign.RequestTemplate;
|
||||
import io.seata.core.context.RootContext;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.web.context.request.RequestContextHolder;
|
||||
import org.springframework.web.context.request.ServletRequestAttributes;
|
||||
|
||||
@Configuration
|
||||
public class FeignSeataConfig extends FeignConfig {
|
||||
|
||||
@Override
|
||||
public void apply(RequestTemplate template) {
|
||||
super.apply(template);
|
||||
|
||||
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
|
||||
if (null != attributes) {
|
||||
String xid = RootContext.getXID();
|
||||
if (StringUtils.isNotEmpty(xid)) {
|
||||
template.header(RootContext.KEY_XID, xid);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user