我正在为Jenkins和Sonarqube创建一个本地实例。 创建项目后,配置相同后,我点击“立即生成”。 在控制台输出中,我可以看到Maven开始下载所需的元数据,一旦完成,它会为每个文件抛出编译错误“找不到符号”该项目。
Maven也安装在我的机器上,我尝试从GIT下载项目并通过命令提示符运行maven,它成功构建。只有我通过詹金斯建立我才会遇到这个问题。有人可以帮我解决这个问题。
声纳错误
[错误]无法在项目XXXXXXX上执行目标org.codehaus.mojo:sonar-maven-plugin:2.6:sonar(default-cli):目标org.codehaus.mojo的执行default-cli:sonar-maven-插件:2.6:声纳失败:执行org.codehaus.mojo时遇到API不兼容:sonar-maven-plugin:2.6:sonar:java.lang.UnsupportedClassVersionError:org / sonar / api / utils / SonarException:不支持的major.minor版本51.0
[ERROR] -------------------------------------------- ---------
[错误] realm = plugin> org.codehaus.mojo:sonar-maven-plugin:2.6
[错误]策略= org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls [0] = file:/ C:/ Program%20Files%20(x86)/ Jenkins / maven-repositories /1/org/codehaus/mojo/sonar-maven-plugin/2.6/sonar-行家-插件-2.6.jar
[ERROR] urls [1] = file:/ C:/ Program%20Files%20(x86)/Jenkins/maven-repositories/1/org/apache/maven/shared/maven-dependency-tree/2.1/行家依赖性树-2.1.jar
[ERROR] urls [2] = file:/ C:/ Program%20Files%20(x86)/Jenkins/maven-repositories/1/backport-util-concurrent/backport-util-concurrent/3.1/backport- util的并发-3.1.jar
[ERROR] urls [3] = file:/ C:/ Program%20Files%20(x86)/Jenkins/maven-repositories/1/org/codehaus/plexus/plexus-interpolation/1.11/plexus-interpolation- 1.11.jar
[ERROR] urls [4] = file:/ C:/ Program%20Files%20(x86)/Jenkins/maven-repositories/1/org/codehaus/plexus/plexus-component-annotations/1.5.5/丛组分的注解-1.5.5.jar
[ERROR] urls [5] = file:/ C:/ Program%20Files%20(x86)/Jenkins/maven-repositories/1/org/eclipse/aether/aether-util/0.9.0.M2/乙醚-UTIL-0.9.0.M2.jar
[ERROR] urls [6] = file:/ C:/ Program%20Files%20(x86)/Jenkins/maven-repositories/1/org/sonatype/plexus/plexus-sec-dispatcher/1.4/plexus-仲调度-1.4.jar
[ERROR] urls [7] = file:/ C:/ Program%20Files%20(x86)/Jenkins/maven-repositories/1/org/codehaus/plexus/plexus-utils/1.5.5/plexus- utils的-1.5.5.jar
[ERROR] urls [8] = file:/ C:/ Program%20Files%20(x86)/Jenkins/maven-repositories/1/org/sonatype/plexus/plexus-cipher/1.4/plexus-cipher- 1.4.jar
[ERROR] urls [9] = file:/ C:/ Program%20Files%20(x86)/Jenkins/maven-repositories/1/org/codehaus/sonar/runner/sonar-runner-api/2.4/声纳浇道-API-2.4.jar
[ERROR] urls [10] = file:/ C:/ Program%20Files%20(x86)/Jenkins/maven-repositories/1/commons-lang/commons-lang/2.6/commons-lang-2.6。罐
[ERROR] urls [11] = file:/ C:/ Program%20Files%20(x86)/Jenkins/maven-repositories/1/com/google/guava/guava/10.0.1/guava-10.0。 1.jar
[ERROR] urls [12] = file:/ C:/ Program%20Files%20(x86)/Jenkins/maven-repositories/1/com/google/code/findbugs/jsr305/2.0.3/jsr305- 2.0.3.jar
[ERROR]国外进口数量:1
[错误]导入:输入[从领域导入ClassRealm [project> com.XXXX.etl:XXXX:0.0.1-SNAPSHOT,parent:ClassRealm [maven.api,parent:null]]
[ERROR]
[ERROR] -------------------------------------------- ---------
[错误] - > [帮助1]
答案 0 :(得分:3)
请指定Java的编译版本。这就是您遇到此问题的原因 - UnsupportedClassVersionError 尝试在你的pom.xml中添加这样的东西
<build>
<plugins>
<!-- START Of Plugins -->
<!-- MAVEN COMPILER PLUGIN -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<!-- END Of Plugins -->
</plugins>
</build>
这里我使用了1.7 jdk。但如果需要,你可以改变它。
请知道它是否有效......
答案 1 :(得分:0)
我有同样的错误。问题是 Jenkins 服务运行在 JRE 上,即使系统中正确配置了 JDK。为了解决这个问题,我不得不停止Jenkins服务,删除JRE,修改Jenkins XML指向JDK,然后重启Jenkins服务。直到那时它才起作用。