“save‘s“ @Transactional requirement is incompatible with the one for this method.

一、sonarqube问题描述

“save‘s“ @Transactional requirement is incompatible with the one for this method._第1张图片

二、问题分析

当使用Spring代理时,使用不兼容的@Transactional要求调用同一类中的方法(例如this.aMethod())将导致运行时异常,因为Spring只“看到”调用者,而没有适当调用被调用者的规定。

因此,某些调用不应在同一类中进行:

序号

From

To

1

non-@Transactional

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 @Transactional

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 syncRsCfgpoint() {

你可能感兴趣的:(sonarqube,数据库,java)