report this on Sonar Community: Commons-lang StringUtils isNotBlank method still raise NPE
有人遇到了相同的問題,官方猜測是沒有正確的配置sonar.java.libraries
SonarQube上的確提示——
Bytecode of dependencies was not provided for analysis of source files, you might end up with less precise results. Bytecode can be provided using sonar.java.libraries property.
手動驗證,將commons-lang3-3.7.jar添加到sonar.java.libraries參數(shù)里,問題解決。
下一步需要處理的方式——
added the target “dependency:copy-dependencies” as part of the maven execution. This copied all the dependencies to the right location, then I set the property “-Dsonar.java.libraries=target/dependency” in our case.
將項目的依賴都復(fù)制到固定的目錄,然后將這個目錄傳遞給sonar.java.libraries參數(shù)。
dependency:copy-dependencies的官方用法。
理論上這樣就可以解決這個問題,需要驗證的是多模塊的項目的依賴是否可以全部正確復(fù)制到正確的目錄下。