作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在为 Jenkins 和 Sonarqube 创建一个本地实例。创建项目并进行配置后,我单击“立即构建”。在控制台输出中,我可以看到 Maven 开始下载所需的元数据,一旦完成,它就会抛出 编译错误“找不到符号”项目。
Maven 也安装在我的机器上,我尝试从 GIT 下载项目并通过命令提示符运行 maven,它成功构建。只有当我通过 Jenkins 构建时,我才会遇到这个问题。有人可以帮我解决这个问题吗。
Sonar 错误
[ERROR] Failed to execute goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar (default-cli) on project XXXXXXX: Execution default-cli of goal org.codehaus.mojo:sonar-maven-plugin:2.6:sonar failed: An API incompatibility was encountered while executing org.codehaus.mojo:sonar-maven-plugin:2.6:sonar: java.lang.UnsupportedClassVersionError: org/sonar/api/utils/SonarException : Unsupported major.minor version 51.0
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>org.codehaus.mojo:sonar-maven-plugin:2.6
[ERROR] strategy = 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-maven-plugin-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/maven-dependency-tree-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-concurrent-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/plexus-component-annotations-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/aether-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-sec-dispatcher-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/sonar-runner-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.jar
[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] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[project>com.XXXX.etl:XXXX:0.0.1-SNAPSHOT, parent: ClassRealm[maven.api, parent: null]]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] -> [Help 1]
最佳答案
请注明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。但如果需要,您可以更改它。
请告诉我它是否有效...
关于Maven 在 Jenkins 中抛出 "Cannot find symbol",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32605160/
我是一名优秀的程序员,十分优秀!