gpt4 book ai didi

java - 如何在 Travis CI 中测试 Java 8?

转载 作者:行者123 更新时间:2023-12-01 09:09:53 24 4
gpt4 key购买 nike

我正在尝试运行 Travis CI 测试。像这样:

language: java
jdk: oraclejdk8
sudo: false
script: mvn test

它应该非常简单......但我得到这个错误:

 diamond operator is not supported in -source 1.5
(use -source 7 or higher to enable diamond operator)
lambda expressions are not supported in -source 1.5
(use -source 8 or higher to enable lambda expressions)

它应该是 Java 8,对吧? 如何配置 Travis CI 运行 Java 8 而不是 Java 5?

欢迎任何帮助!

编辑

这是我的 POM:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>br.com.simplepass</groupId>
<artifactId>mapPointManager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>mapPointManager</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.5.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

最佳答案

您应该在 pom 脚本中添加以下标记:

<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</build>

这将使您的源代码和目标编译为 java 1.8。顺便说一句,我有一个 GitHub使用Java 8和Travis的项目,你可以看看!你的整个 pom 会是这样的:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>br.com.simplepass</groupId>
<artifactId>mapPointManager</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>

<name>mapPointManager</name>
<url>http://maven.apache.org</url>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</build>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.5.2</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

关于java - 如何在 Travis CI 中测试 Java 8?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40985584/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com