问题描述
我刚下载了最新版本,SonarQube 4.3,
然后尝试使用以下内容构建一个java-8项目:
I just downloaded the latest version, SonarQube 4.3,then try build a java-8 project with:
mvn clean install
mvn sonar:sonar
这给了我下面的例外。
谷歌搜索,我得到的印象是这是一个应该修复的早期问题......?
Googling, I got the impression this is an earlier issue that should have been fixed... ?
SonarQube 4.3是否支持java-8?
Does SonarQube 4.3 support java-8?
或任何线索,有什么问题?
Or any clue, what is the problem?
-------------------------------------------------------
T E S T S
-------------------------------------------------------
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at sun.instrument.InstrumentationImpl.loadClassAndStartAgent(InstrumentationImpl.java:386)
at sun.instrument.InstrumentationImpl.loadClassAndCallPremain(InstrumentationImpl.java:401)
Caused by: java.lang.RuntimeException: Class java/util/UUID could not be instrumented.
at org.jacoco.agent.rt.internal_6effb9e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:138)
at org.jacoco.agent.rt.internal_6effb9e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:99)
at org.jacoco.agent.rt.internal_6effb9e.PreMain.createRuntime(PreMain.java:55)
at org.jacoco.agent.rt.internal_6effb9e.PreMain.premain(PreMain.java:47)
... 6 more
Caused by: java.lang.NoSuchFieldException: $jacocoAccess
at java.lang.Class.getField(Class.java:1690)
at org.jacoco.agent.rt.internal_6effb9e.core.runtime.ModifiedSystemClassRuntime.createFor(ModifiedSystemClassRuntime.java:136)
... 9 more
FATAL ERROR in native method: processing of -javaagent failed
Exception in thread "main"
推荐答案
我从SonarQube邮件列表中得到了缺失的信息...
要su mmarize:
I got the missing info from the SonarQube mailing-list...To summarize:
要在SonarQube-4.3上运行Java8 maven-build:
To get Java8 maven-build working on SonarQube-4.3:
-
安装sonarqube-4.3,然后启动服务器。
Install sonarqube-4.3, and start the server.
登录 web-gui =>设置=>更新中心=>插件更新=> Java =>点击升级到2.2.1
等一下或所以升级完成...然后关机+重启sonarqube。
返回升级中心并验证您是否有插件: Java 2.2.1
Wait a minute or so for the upgrade to complete... then shutdown+restart sonarqube.Go back into the Upgrade Center and verify you have plugin: Java 2.2.1
-
要在Sonar中获得代码覆盖率,您现在需要使用以下命令构建:
To get code-coverage in Sonar, you now need to build with these commands:
mvn clean org.jacoco:jacoco-maven-plugin:prepare-agent install
mvn sonar:sonar
参考:
就是这样。
这篇关于Java8项目上的SonarQube提供了jacoco-Exception的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!