SonarQubeMojo 的 SonarQube Intellij 插件错误
SonarQube Intellij Plugin error with SonarQubeMojo
我在使用 运行 intellij SonarQube 插件时遇到问题。连接到我的声纳服务器后,我可以看到可供我使用的不同项目。我现在正在尝试将其设置为本地分析。
我本地的分析脚本如下
mvn.bat sonar:sonar -Dmaven.compiler.source=1.7 -Dmaven.compiler.target=1.7 -DskipTests=true -Dsonar.language=java -Dsonar.analysis.mode=incremental -Dsonar.host.url=https://www.sonarserver -Dsonar.login=admin -Dsonar.password=●●●●●●●
我得到的错误是这样的,
ERROR 11:59:09.944 > Aug 5, 2016 11:59:09 AM org.sonatype.guice.bean.reflect.Logs$JULSink warn
ERROR 11:59:09.945 > WARNING: Error injecting: org.sonarsource.scanner.maven.SonarQubeMojo
ERROR 11:59:09.945 > java.lang.TypeNotPresentException: Type org.sonarsource.scanner.maven.SonarQubeMojo not present
ERROR 11:59:09.945 > at org.sonatype.guice.bean.reflect.URLClassSpace.loadClass(URLClassSpace.java:109)
ERROR 11:59:09.945 > at org.sonatype.guice.bean.reflect.NamedClass.load(NamedClass.java:45)
ERROR 11:59:09.945 > at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:45)
ERROR 11:59:09.945 > at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:84)
ERROR 11:59:09.945 > at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:52)
ERROR 11:59:09.945 > at com.google.inject.internal.ProviderInternalFactory.call(ProviderInternalFactory.java:70)
ERROR 11:59:09.945 > at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
ERROR 11:59:09.945 > at org.sonatype.guice.plexus.lifecycles.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:138)
ERROR 11:59:09.945 > at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:108)
ERROR 11:59:09.945 > at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
ERROR 11:59:09.945 > at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
ERROR 11:59:09.945 > at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
ERROR 11:59:09.945 > at com.google.inject.internal.InjectorImpl.call(InjectorImpl.java:965)
ERROR 11:59:09.945 > at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1011)
ERROR 11:59:09.945 > at com.google.inject.internal.InjectorImpl.get(InjectorImpl.java:961)
ERROR 11:59:09.945 > at com.google.inject.Scopes.get(Scopes.java:59)
ERROR 11:59:09.945 > at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83)
ERROR 11:59:09.945 > at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49)
ERROR 11:59:09.945 > at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253)
ERROR 11:59:09.945 > at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245)
ERROR 11:59:09.945 > at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:455)
ERROR 11:59:09.945 > at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
ERROR 11:59:09.945 > at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
ERROR 11:59:09.945 > at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
ERROR 11:59:09.945 > at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
ERROR 11:59:09.945 > at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
ERROR 11:59:09.945 > at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
ERROR 11:59:09.945 > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
ERROR 11:59:09.945 > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
ERROR 11:59:09.945 > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
ERROR 11:59:09.945 > at java.lang.reflect.Method.invoke(Method.java:597)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
ERROR 11:59:09.945 > Caused by: java.lang.UnsupportedClassVersionError: org/sonarsource/scanner/maven/SonarQubeMojo : Unsupported major.minor version 51.0
ERROR 11:59:09.945 > at java.lang.ClassLoader.defineClass1(Native Method)
ERROR 11:59:09.945 > at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
ERROR 11:59:09.945 > at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
ERROR 11:59:09.945 > at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
ERROR 11:59:09.945 > at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
ERROR 11:59:09.945 > at java.net.URLClassLoader.access[=11=]0(URLClassLoader.java:58)
ERROR 11:59:09.945 > at java.net.URLClassLoader.run(URLClassLoader.java:197)
ERROR 11:59:09.945 > at java.security.AccessController.doPrivileged(Native Method)
ERROR 11:59:09.945 > at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:386)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
ERROR 11:59:09.945 > at org.sonatype.guice.bean.reflect.URLClassSpace.loadClass(URLClassSpace.java:101)
ERROR 11:59:09.945 > ... 41 more
INFO 11:59:09.970 > [INFO] ------------------------------------------------------------------------
INFO 11:59:09.970 > [INFO] BUILD FAILURE
INFO 11:59:09.970 > [INFO] ------------------------------------------------------------------------
INFO 11:59:09.972 > [INFO] Total time: 9.480s
INFO 11:59:09.978 > [INFO] Finished at: Fri Aug 05 11:59:09 EDT 2016
INFO 11:59:10.199 > [INFO] Final Memory: 27M/227M
INFO 11:59:10.200 > [INFO] ------------------------------------------------------------------------
INFO 11:59:10.239 > [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project cruw-ui: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar failed: Unable to load the mojo 'sonar' in the plugin 'org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/sonarsource/scanner/maven/SonarQubeMojo : Unsupported major.minor version 51.0
我搜索了类似的问题,说是需要用1.7以上版本编译。我已经在我的脚本中定义了编译器和源目标,所以它应该使用 1.7,对吗?我还缺少什么?
所以看来问题是即使我在命令行中设置了 Maven,它仍然使用错误的 java 版本。我所做的是手动设置 JAVA_HOME 环境变量以指向我的 Java 1.8 JDK 安装路径。这样做之后,sonarqube 似乎可以工作了。
我在使用 运行 intellij SonarQube 插件时遇到问题。连接到我的声纳服务器后,我可以看到可供我使用的不同项目。我现在正在尝试将其设置为本地分析。
我本地的分析脚本如下
mvn.bat sonar:sonar -Dmaven.compiler.source=1.7 -Dmaven.compiler.target=1.7 -DskipTests=true -Dsonar.language=java -Dsonar.analysis.mode=incremental -Dsonar.host.url=https://www.sonarserver -Dsonar.login=admin -Dsonar.password=●●●●●●●
我得到的错误是这样的,
ERROR 11:59:09.944 > Aug 5, 2016 11:59:09 AM org.sonatype.guice.bean.reflect.Logs$JULSink warn
ERROR 11:59:09.945 > WARNING: Error injecting: org.sonarsource.scanner.maven.SonarQubeMojo
ERROR 11:59:09.945 > java.lang.TypeNotPresentException: Type org.sonarsource.scanner.maven.SonarQubeMojo not present
ERROR 11:59:09.945 > at org.sonatype.guice.bean.reflect.URLClassSpace.loadClass(URLClassSpace.java:109)
ERROR 11:59:09.945 > at org.sonatype.guice.bean.reflect.NamedClass.load(NamedClass.java:45)
ERROR 11:59:09.945 > at org.sonatype.guice.bean.reflect.AbstractDeferredClass.get(AbstractDeferredClass.java:45)
ERROR 11:59:09.945 > at com.google.inject.internal.ProviderInternalFactory.provision(ProviderInternalFactory.java:84)
ERROR 11:59:09.945 > at com.google.inject.internal.InternalFactoryToInitializableAdapter.provision(InternalFactoryToInitializableAdapter.java:52)
ERROR 11:59:09.945 > at com.google.inject.internal.ProviderInternalFactory.call(ProviderInternalFactory.java:70)
ERROR 11:59:09.945 > at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:100)
ERROR 11:59:09.945 > at org.sonatype.guice.plexus.lifecycles.PlexusLifecycleManager.onProvision(PlexusLifecycleManager.java:138)
ERROR 11:59:09.945 > at com.google.inject.internal.ProvisionListenerStackCallback$Provision.provision(ProvisionListenerStackCallback.java:108)
ERROR 11:59:09.945 > at com.google.inject.internal.ProvisionListenerStackCallback.provision(ProvisionListenerStackCallback.java:55)
ERROR 11:59:09.945 > at com.google.inject.internal.ProviderInternalFactory.circularGet(ProviderInternalFactory.java:68)
ERROR 11:59:09.945 > at com.google.inject.internal.InternalFactoryToInitializableAdapter.get(InternalFactoryToInitializableAdapter.java:45)
ERROR 11:59:09.945 > at com.google.inject.internal.InjectorImpl.call(InjectorImpl.java:965)
ERROR 11:59:09.945 > at com.google.inject.internal.InjectorImpl.callInContext(InjectorImpl.java:1011)
ERROR 11:59:09.945 > at com.google.inject.internal.InjectorImpl.get(InjectorImpl.java:961)
ERROR 11:59:09.945 > at com.google.inject.Scopes.get(Scopes.java:59)
ERROR 11:59:09.945 > at org.sonatype.guice.bean.locators.LazyBeanEntry.getValue(LazyBeanEntry.java:83)
ERROR 11:59:09.945 > at org.sonatype.guice.plexus.locators.LazyPlexusBean.getValue(LazyPlexusBean.java:49)
ERROR 11:59:09.945 > at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:253)
ERROR 11:59:09.945 > at org.codehaus.plexus.DefaultPlexusContainer.lookup(DefaultPlexusContainer.java:245)
ERROR 11:59:09.945 > at org.apache.maven.plugin.internal.DefaultMavenPluginManager.getConfiguredMojo(DefaultMavenPluginManager.java:455)
ERROR 11:59:09.945 > at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:92)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
ERROR 11:59:09.945 > at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
ERROR 11:59:09.945 > at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
ERROR 11:59:09.945 > at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
ERROR 11:59:09.945 > at org.apache.maven.cli.MavenCli.execute(MavenCli.java:537)
ERROR 11:59:09.945 > at org.apache.maven.cli.MavenCli.doMain(MavenCli.java:196)
ERROR 11:59:09.945 > at org.apache.maven.cli.MavenCli.main(MavenCli.java:141)
ERROR 11:59:09.945 > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
ERROR 11:59:09.945 > at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
ERROR 11:59:09.945 > at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
ERROR 11:59:09.945 > at java.lang.reflect.Method.invoke(Method.java:597)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.launcher.Launcher.launchEnhanced(Launcher.java:290)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:230)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.launcher.Launcher.mainWithExitCode(Launcher.java:409)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.launcher.Launcher.main(Launcher.java:352)
ERROR 11:59:09.945 > Caused by: java.lang.UnsupportedClassVersionError: org/sonarsource/scanner/maven/SonarQubeMojo : Unsupported major.minor version 51.0
ERROR 11:59:09.945 > at java.lang.ClassLoader.defineClass1(Native Method)
ERROR 11:59:09.945 > at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
ERROR 11:59:09.945 > at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
ERROR 11:59:09.945 > at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
ERROR 11:59:09.945 > at java.net.URLClassLoader.defineClass(URLClassLoader.java:283)
ERROR 11:59:09.945 > at java.net.URLClassLoader.access[=11=]0(URLClassLoader.java:58)
ERROR 11:59:09.945 > at java.net.URLClassLoader.run(URLClassLoader.java:197)
ERROR 11:59:09.945 > at java.security.AccessController.doPrivileged(Native Method)
ERROR 11:59:09.945 > at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClassFromSelf(ClassRealm.java:386)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy.loadClass(SelfFirstStrategy.java:42)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:244)
ERROR 11:59:09.945 > at org.codehaus.plexus.classworlds.realm.ClassRealm.loadClass(ClassRealm.java:230)
ERROR 11:59:09.945 > at org.sonatype.guice.bean.reflect.URLClassSpace.loadClass(URLClassSpace.java:101)
ERROR 11:59:09.945 > ... 41 more
INFO 11:59:09.970 > [INFO] ------------------------------------------------------------------------
INFO 11:59:09.970 > [INFO] BUILD FAILURE
INFO 11:59:09.970 > [INFO] ------------------------------------------------------------------------
INFO 11:59:09.972 > [INFO] Total time: 9.480s
INFO 11:59:09.978 > [INFO] Finished at: Fri Aug 05 11:59:09 EDT 2016
INFO 11:59:10.199 > [INFO] Final Memory: 27M/227M
INFO 11:59:10.200 > [INFO] ------------------------------------------------------------------------
INFO 11:59:10.239 > [ERROR] Failed to execute goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar (default-cli) on project cruw-ui: Execution default-cli of goal org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2:sonar failed: Unable to load the mojo 'sonar' in the plugin 'org.sonarsource.scanner.maven:sonar-maven-plugin:3.0.2' due to an API incompatibility: org.codehaus.plexus.component.repository.exception.ComponentLookupException: org/sonarsource/scanner/maven/SonarQubeMojo : Unsupported major.minor version 51.0
我搜索了类似的问题,说是需要用1.7以上版本编译。我已经在我的脚本中定义了编译器和源目标,所以它应该使用 1.7,对吗?我还缺少什么?
所以看来问题是即使我在命令行中设置了 Maven,它仍然使用错误的 java 版本。我所做的是手动设置 JAVA_HOME 环境变量以指向我的 Java 1.8 JDK 安装路径。这样做之后,sonarqube 似乎可以工作了。