简体   繁体   English

Travis CI 使用错误版本的 Java

[英]Travis CI using the wrong version of Java

I've been trying to set up a Maven Project (Spring Boot) and connect it to Travis CI for the past 12 hours and it keeps failing.在过去的 12 小时里,我一直在尝试设置 Maven 项目(Spring Boot)并将其连接到 Travis CI,但一直失败。 It's driving me crazy.这让我疯狂。 It looks like the virtual environment on Travis CI website is using the wrong version of Java as seen here看起来 Travis CI 网站上的虚拟环境使用了错误版本的 Java,如此处所示

这里

and

here这里这里

Here are a few more screenshots that might helpful:以下是一些可能有帮助的屏幕截图:

My.bash_profile and JAVA_HOME are correctly set My.bash_profile 和 JAVA_HOME 设置正确

JAVA_HOME

bash_profile

and finally my.travis.yml inside my spring boot project最后是我的 spring 引导项目中的 my.travis.yml

特拉维斯

I created my Spring Boot project using this site: https://start.spring.io/ I didn't change anything expect the java version, I set it to 13 I created my Spring Boot project using this site: https://start.spring.io/ I didn't change anything expect the java version, I set it to 13

Here's what my pom.xml looks like:这是我的 pom.xml 的样子:

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.2.1.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.example</groupId>
    <artifactId>demo</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>demo</name>
    <description>Demo project for Spring Boot</description>

    <properties>
        <java.version>13</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.8.0</version>
                <configuration>
                    <source>13</source> <!-- 1.8,1.9,1.10,11,12,13 -->
                    <target>13</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

</project>

Please help.请帮忙。 Thank you.谢谢你。

You have to specify the jdk version that you want to use in your Travis CI configuration file:您必须在 Travis CI 配置文件中指定要使用的 jdk 版本:

language: java

jdk:
  - oraclejdk8
  - openjdk8

More information about setting up java projects in Travis CI here .有关在 Travis CI 中设置 java 项目的更多信息,请点击此处

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

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