【问题标题】:Sonar Doesn't pick lombok Annotations ( Remove unused private field)Sonar 不选择 lombok 注释(删除未使用的私有字段)
【发布时间】:2022-02-01 00:52:42
【问题描述】:

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

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

1)

<sonar.exclusions>
        // my domain package here
        </sonar.exclusions>
  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>
    

然后添加以下属性

<sonar.java.libraries>target/dependency/*.jar</sonar.java.libraries>
  1. 添加 lombok.config 并添加以下属性

    config.stopBubbling = true lombok.addLombokGeneratedAnnotation = true

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

【问题讨论】:

    标签: java spring spring-boot sonarqube lombok


    【解决方案1】:
    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.
    

    【讨论】:

      猜你喜欢
      • 2020-02-07
      • 1970-01-01
      • 2020-02-04
      • 2017-07-25
      • 1970-01-01
      • 2017-12-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多