Sonar 不选择 lombok 注释(删除未使用的私有字段)

Mad*_*ddy 5 java spring lombok spring-boot sonarqube

我使用的是声纳版本 8.9.6。我知道这个问题已经被问过很多次了,我已经尝试了很多,但没有一个解决方案对我有用。

以下是我尝试过的一些事情。

1)

<sonar.exclusions>
        // my domain package here
        </sonar.exclusions>
Run Code Online (Sandbox Code Playgroud)
  1. 添加了以下插件

               <plugin>
       <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-dependency-plugin</artifactId>
            <executions>
              <execution>
                <id>copy-dependencies</id>
                <phase>package</phase>
                <goals>
                  <goal>copy-dependencies</goal>
                </goals>
                <configuration>
                  <includeArtifactIds>lombok</includeArtifactIds>
                </configuration>
              </execution>
            </executions>
          </plugin>
    
    Run Code Online (Sandbox Code Playgroud)

然后添加以下属性

<sonar.java.libraries>target/dependency/*.jar</sonar.java.libraries>
Run Code Online (Sandbox Code Playgroud)
  1. 添加了 lombok.config 并添加了以下属性

    config.stopBubbling = true lombok.addLombokGenerateAnnotation = true

这些对我来说都不起作用,尤其是声纳排除根本不起作用。如有任何帮助,我们将不胜感激,并提前致谢。

KM *_*WAL 0

Please try to add the following dependency into your pom.xml file
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
        </dependency>

and Download lombok.jar from the given link
https://projectlombok.org/download

Now if it is zipped unzip it first and then copy it to the directory 
where you have your SpringToolSuits(STS installed).

Let say your STS version is 4.11.0.RELEASE then copy lombok.jar to STS 
directory/sts-4.11.0.RELEASE   i.e. inside STS/sts-4.11.0.RELEASE/

Now try to rebuild and update your project.
Run Code Online (Sandbox Code Playgroud)