@Yashin 你好,想跟你请教个问题:我按照该教程学习Sonar,但是最后一步利用SonarScanner分析工具分析源代码时报错,我在同事电脑按照这个步骤是没有问题的,且我使用的Java环境软件版本均一致,请教一下该问题是什么原因造成的,非常感谢!(该问题已经解决3天了,实在无能为力了)教程链接:http://www.cnblogs.com/qiaoyeye/p/5249786.htmlSonarScanner。
SQL:
DROP DATABASE sonar;
CREATE DATABASE sonar CHARACTER SET utf8 COLLATE utf8_general_ci;
CREATE USER 'sonar' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'%' IDENTIFIED BY 'sonar';
GRANT ALL ON sonar.* TO 'sonar'@'localhost' IDENTIFIED BY 'sonar';
FLUSH PRIVILEGES;
连接的参数均为
sonar.jdbc.url=jdbc:mysql://localhost:3306/sonar?useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true&useConfigs=maxPerformance
sonar.jdbc.username=sonar
sonar.jdbc.password=sonar
sonar.sorceEncoding=UTF-8
sonar.login=admin
sonar.password=admin
黑框是 sonar-scanner报的错?有提示加-e参数查看详细错误堆栈了,有试过吗?详细错误堆栈贴出来看看?下面白框应该是sonarweb的日志吧,最好提问描述清晰一下上下文哦,比如执行了哪个命令报,就丢个链接这样很难有人有时间猜测一下再研究一下再跟你交流的。
sonar-runner-e看看详细错误堆栈,如果真是插件无法下载就看看以下目录是否有相应的插件了,没有的话要先下载插件Sonar/extensions/plugins并且建议入门一个软件或者技术最好按官方文档来目前学习Sonar工具来分析源码。
以下是操作步骤
1.配置数据库,创建一个sonar数据库。
2.启动Sonar服务,通过sonarqube安装目录下的sonar.properties文件初始化数据库(数据库初始化成功)
3.利用SonarScanner工具执行源码分析。需要配置环境变量name=SONAR_RUNNER_HOME。value=D:\sonar\sonar-scanner-2.5,并且在需要分析的项目根目录,创建建sonar-project.properties文件,以上工作全部完成。
4.启动sonarqube服务,并启动cmd,在cmd进入项目所在的根目录,输入命令:sonar-runner
正常是能执行代码分析的,但是此处加载插件时失败。(可以排除各个软件版本的问题)
sonar-runner-e
C:\Users\Administrator\Desktop\sonar\netctoss>sonar-runner-e
C:\Users\Administrator\Desktop\sonar\sonar-scanner-2.5
INFO:Scannerconfigurationfile:C:\Users\Administrator\Desktop\sonar\sonar-scanner-2.5\conf\sonar-runner.properties
INFO:Projectconfigurationfile:C:\Users\Administrator\Desktop\sonar\netctoss\sonar-project.properties
INFO:SonarQubeScanner2.5
INFO:Java1.7.0_80OracleCorporation(64-bit)
INFO:Windows8.16.3amd64
INFO:Errorstacktracesareturnedon.
INFO:Usercache:C:\Users\Administrator\.sonar\cache
INFO:Loadglobalrepositories
INFO:Loadglobalrepositories(done)|time=169ms
INFO:Property'sonar.jdbc.url'isnotsupportedanymore.Itwillbeignored.ThereisnolongeranyDBconnectiontotheSQdatabase.
INFO:Property'sonar.jdbc.username'isnotsupportedanymore.Itwillbeignored.ThereisnolongeranyDBconnectiontotheSQdatabase.
INFO:Property'sonar.jdbc.password'isnotsupportedanymore.Itwillbeignored.ThereisnolongeranyDBconnectiontotheSQdatabase.
INFO:Usercache:C:\Users\Administrator\.sonar\cache
INFO:Loadpluginsindex
INFO:------------------------------------------------------------------------
INFO:EXECUTIONFAILURE
INFO:------------------------------------------------------------------------
INFO:Totaltime:1.195s
INFO:FinalMemory:38M/303M
INFO:------------------------------------------------------------------------
ERROR:ErrorduringSonarQubeScannerexecution
org.sonarqube.ws.client.HttpException:Error500onhttp://localhost:9000/deploy/plugins/index.txt
atorg.sonarqube.ws.client.BaseResponse.failIfNotSuccessful(BaseResponse.java:32)
atorg.sonar.batch.bootstrap.BatchWsClient.failIfUnauthorized(BatchWsClient.java:96)
atorg.sonar.batch.bootstrap.BatchWsClient.call(BatchWsClient.java:67)
atorg.sonar.batch.cache.WSLoader$1.load(WSLoader.java:62)
atorg.sonar.batch.cache.WSLoader$1.load(WSLoader.java:58)
atorg.sonar.batch.cache.WSLoader.loadFromServer(WSLoader.java:225)
atorg.sonar.batch.cache.WSLoader.loadFromServerFirst(WSLoader.java:188)
atorg.sonar.batch.cache.WSLoader.load(WSLoader.java:148)
atorg.sonar.batch.cache.WSLoader.loadString(WSLoader.java:134)
atorg.sonar.batch.cache.WSLoader.loadString(WSLoader.java:129)
atorg.sonar.batch.bootstrap.BatchPluginInstaller.loadPluginIndex(BatchPluginInstaller.java:132)
atorg.sonar.batch.bootstrap.BatchPluginInstaller.listRemotePlugins(BatchPluginInstaller.java:117)
atorg.sonar.batch.bootstrap.BatchPluginInstaller.installRemotes(BatchPluginInstaller.java:72)
atorg.sonar.batch.bootstrap.BatchPluginRepository.start(BatchPluginRepository.java:54)
atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
atjava.lang.reflect.Method.invoke(Method.java:606)
atorg.picocontainer.lifecycle.ReflectionLifecycleStrategy.invokeMethod(ReflectionLifecycleStrategy.java:110)
atorg.picocontainer.lifecycle.ReflectionLifecycleStrategy.start(ReflectionLifecycleStrategy.java:89)
atorg.sonar.core.platform.ComponentContainer$1.start(ComponentContainer.java:291)
atorg.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.start(AbstractInjectionFactory.java:84)
atorg.picocontainer.behaviors.AbstractBehavior.start(AbstractBehavior.java:169)
atorg.picocontainer.behaviors.Stored$RealComponentLifecycle.start(Stored.java:132)
atorg.picocontainer.behaviors.Stored.start(Stored.java:110)
atorg.picocontainer.DefaultPicoContainer.potentiallyStartAdapter(DefaultPicoContainer.java:1016)
atorg.picocontainer.DefaultPicoContainer.startAdapters(DefaultPicoContainer.java:1009)
atorg.picocontainer.DefaultPicoContainer.start(DefaultPicoContainer.java:767)
atorg.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:131)
atorg.sonar.batch.bootstrapper.Batch.start(Batch.java:103)
atorg.sonar.runner.batch.BatchIsolatedLauncher.start(BatchIsolatedLauncher.java:57)
atsun.reflect.NativeMethodAccessorImpl.invoke0(NativeMethod)
atsun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
atsun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
atjava.lang.reflect.Method.invoke(Method.java:606)
atorg.sonar.runner.impl.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:61)
atcom.sun.proxy.$Proxy0.start(UnknownSource)
atorg.sonar.runner.api.EmbeddedRunner.doStart(EmbeddedRunner.java:251)
atorg.sonar.runner.api.EmbeddedRunner.start(EmbeddedRunner.java:187)
atorg.sonar.runner.api.EmbeddedRunner.start(EmbeddedRunner.java:182)
atorg.sonarsource.scanner.cli.Main.execute(Main.java:75)
atorg.sonarsource.scanner.cli.Main.main(Main.java:66)
ERROR:
ERROR:Re-runSonarQubeScannerusingthe-Xswitchtoenablefulldebuglogging.
我现在是找到问题所在了,但是为什么造成这样不清楚
请教加载失败的原因。我把在同事电脑正常加载.sonar是文件夹拷贝到根目录下,依旧是报相同的错误,还是得需要它自己正常加载。
sonar-ruuner执行分析之前是要从sonarweb下载插件,你这种情况应该是下载失败了,建议取你同事的环境拷贝 Sonar/sonarqube-5.3/extensions/plugins下的插件。然后重启sonarweb。再试试
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。