2016-08-05 76 views
2

我遇到了運行intellij SonarQube插件的麻煩。在連接到我的聲納服務器後,我可以看到可用於我的不同項目。我現在試圖設置這個爲本地分析。SonarQube Intellij與SonarQubeMojo插件錯誤

我的本地分析腳本如下

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$1.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$3$1.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$3.get(InjectorImpl.java:961) 
ERROR 11:59:09.945 > at com.google.inject.Scopes$1$1.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$000(URLClassLoader.java:58) 
ERROR 11:59:09.945 > at java.net.URLClassLoader$1.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正確的?我還有什麼遺漏?

回答

1

所以看來問題在於,即使在命令行中設置Maven後,Maven仍然使用錯誤的Java版本。我所做的是手動將JAVA_HOME環境變量設置爲指向我的Java 1.8 JDK安裝路徑。這樣做後,sonarqube似乎工作。