一、sonarqube问题描述
二、问题分析
当使用Spring代理时,使用不兼容的@Transactional要求调用同一类中的方法(例如this.aMethod())将导致运行时异常,因为Spring只“看到”调用者,而没有适当调用被调用者的规定。
因此,某些调用不应在同一类中进行:
序号 | From | To |
---|---|---|
1 | non- | MANDATORY, NESTED, REQUIRED, REQUIRES_NEW |
2 | MANDATORY | NESTED, NEVER, NOT_SUPPORTED, REQUIRES_NEW |
3 | NESTED | NESTED, NEVER, NOT_SUPPORTED, REQUIRES_NEW |
4 | NEVER | MANDATORY, NESTED, REQUIRED, REQUIRES_NEW |
5 | NOT_SUPPORTED | MANDATORY, NESTED, REQUIRED, REQUIRES_NEW |
6 | REQUIRED or | NESTED, NEVER, NOT_SUPPORTED, REQUIRES_NEW |
7 | REQUIRES_NEW | NESTED, NEVER, NOT_SUPPORTED, REQUIRES_NEW |
8 | SUPPORTS | MANDATORY, NESTED, NEVER, NOT_SUPPORTED, REQUIRED, REQUIRES_NEW |
三、问题解决
在方法调用上加上@Transactional
@Override
@Transactional(rollbackFor = Exception.class)
public Result<String> syncRsCfgpoint() {