Xiamu-ssr commented on issue #6235:
URL: 
https://github.com/apache/incubator-seata/issues/6235#issuecomment-1876610361

   谢谢。当我把注解全部从接口转移到实现类后,问题解决了。
   这是接口类
   ```java
   public interface AccountTCCService {
   
       boolean deduct(
               BusinessActionContext ctx,
               String userId,
               int money
       );
   
       boolean deductConfirm(BusinessActionContext ctx);
   
       boolean deductCancel(BusinessActionContext ctx);
   
   }
   ```
   
   这是实现类
   ```java
   @Service
   @Slf4j
   @LocalTCC
   public class AccountTCCServiceImpl implements AccountTCCService {
   
       @Autowired
       private AccountMapper accountMapper;
       @Autowired
       private AccountFreezeMapper accountFreezeMapper;
   
       @Override
       @Transactional
       @TwoPhaseBusinessAction(name = "deduct", commitMethod = "deductConfirm", 
rollbackMethod = "deductCancel")
       public boolean deduct(
               BusinessActionContext ctx,
               @BusinessActionContextParameter(paramName = "userId") String 
userId,
               @BusinessActionContextParameter(paramName = "money") int money
       ) {
           System.out.println(ctx);//第一处断点
           if (ctx != null){
               Object userId2 = ctx.getActionContext("userId");
               Object money2 =  ctx.getActionContext("money");
               System.out.println(userId2);
               System.out.println(money2);
           }
           throw new RuntimeException("扣款失败,可能是余额不足!");
       }
   
       @Override
       public boolean deductConfirm(BusinessActionContext ctx) {
           return true;
       }
   
       @Override
       public boolean deductCancel(BusinessActionContext ctx) {
           Object userId = ctx.getActionContext("userId");//第二处断点
           Object money =  ctx.getActionContext("money");
           System.out.println(userId);
           System.out.println(money);
           return false;
       }
   }
   ```
   
![image](https://github.com/apache/incubator-seata/assets/77220168/b93cf8b2-44a1-46c6-ad93-1e295a72424f)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to