单位有同事的jdk版本是1.7,在使用sonarqube的时候一直报异常:
org.sonarsource.scanner.maven.SonarQubeMojo not present
Caused by: java.lang.UnsupportedClassVersionError: org/sonarsource/scanner/maven/SonarQubeMojo : Unsupported major.minor version 52.0
java.lang.TypeNotPresentException: Type org.sonarsource.scanner.maven.SonarQubeMojo not present
百度了一堆结果,最后在github上发现了解决方法:
https://github.com/sonar-intellij-plugin/sonar-intellij-plugin/issues/167
also this is unrelated to the plugin, sonarqube has updated the default version of the sonar-maven-plugin to version 3.2. This requires java 8.
To solve the issue you need to update the JAVA_HOME to version 1.8 or use older version of sonar-maven-plugin, example:
export JAVA_HOME="/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home/"
or
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>sonar-maven-plugin</artifactId>
<version>2.6</version>
</plugin>
就是说sonarqube默认已经升级到jdk1.8了,自动下载的sonar-maven-plugin是3.3.x,不支持1.8以下的版本了,如果你一定要用旧版本,就下载sonar-maven-plugin2.6。
问题解决了!