简体   繁体   English

使用CircleCI执行时无法解析Java 8导入

[英]Java 8 import cannot be resolved when executing with CircleCI

I have a Java 8 project, built with maven. 我有一个用Maven构建的Java 8项目。 I'm using CircleCI as continuous integration, and I get the following error message during the build: 我使用CircleCI作为持续集成,并且在构建过程中收到以下错误消息:

import java.util.function.Consumer;
       ^^^^^^^^^^^^^^^^^^
The import java.util.function cannot be resolved

I have: 我有:

<source>1.8</source>
<target>1.8</target>

in my maven-compiler plugin. 在我的maven-compiler插件中。 When I run the build locally, with mvn clean install , or with mvn integration-test , as it is executed in CircleCI, I get no errors. 当我在CircleCI中执行构建时,使用mvn clean installmvn integration-test在本地运行该构建时,没有任何错误。

Is there some problem when using CircleCI with a Java 8 project? 将CircleCI与Jav​​a 8项目一起使用时会出现问题吗?

The project source can be found here: https://github.com/verjigorm/DragonPunch.git 该项目的源代码可以在这里找到: https : //github.com/verjigorm/DragonPunch.git

Edit: I had a look at the links suggested below, and fixed the build by adding: 编辑:我看了下面建议的链接,并通过添加以下内容修复了构建:

machine:
  java:
    version:
      oraclejdk8

to my circle.yml file. 到我的circle.yml文件。

Just because you specify that you want to use Java 8 in your pom file does not mean it's going to be available. 仅仅因为您指定要在pom文件中使用Java 8并不意味着它将可用。

According to the Circle Documentation , they default to oraclejdk7 as the Java runtime. 根据Circle Documentation ,它们默认使用oraclejdk7作为Java运行时。 You'll have to specify something that supports Java 8, like oraclejdk8 instead. 您必须指定一些支持Java 8的内容,例如oraclejdk8

According to CircleCi documentation , it uses by default Java 1.7.0_55 根据CircleCi文档 ,默认情况下使用Java 1.7.0_55

Check the configuration to set a JDK 8 instead of this 检查配置以设置JDK 8而不是此设置

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM