【问题标题】:Github Actions build Java Maven project gives error: Fatal error compiling: error: invalid target release: 18 -> [Help 1]Github Actions 构建 Java Maven 项目时出现错误:Fatal error compiling: error: invalid target release: 18 -> [Help 1]
【发布时间】:2022-12-03 14:33:34
【问题描述】:

我正在为我的(第一个)Spring Boot 应用程序设置工作流。当它运行时,它会在 run 命令处给出错误。我不太确定要更改什么,因为我对 SpringBoot 或 Java 不太熟悉。

错误:

Error:  Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile (default-compile) on project Workethic: Fatal error compiling: error: invalid target release: 18 -> [Help 1]
Error:  
Error:  To see the full stack trace of the errors, re-run Maven with the -e switch.
Error:  Re-run Maven using the -X switch to enable full debug logging.
Error:  
Error:  For more information about the errors and possible solutions, please read the following articles:
Error:  [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException
Error: Process completed with exit code 1.

我在 IntelliJ 中查看并看到了这个,这与此有什么关系吗?如果是,为什么它对 Github 工作流程很重要? https://gyazo.com/1ab85231aa6743bc0ef8de28756f40fc

pom.xml:

<build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
                <version>${project.parent.version}</version>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>${maven-compiler-plugin.version}</version>
                <configuration>
                    <source>18</source>
                    <target>18</target>
                </configuration>
            </plugin>
        </plugins>
    </build>

工作流程:

jobs:
  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v3
    - name: Set up JDK 11
      uses: actions/setup-java@v3
      with:
        java-version: '11'
        distribution: 'temurin'
        cache: maven
    - name: Build with Maven
      run: mvn clean install

    # Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
    - name: Update dependency graph
      uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6

【问题讨论】:

    标签: java spring-boot github-actions


    【解决方案1】:

    如果您查看此页面: https://github.com/actions/setup-java#supported-version-syntax 您可以看到 jdk 18 不是 github 工作流程支持的版本,请尝试将其设置为 17。

    【讨论】:

      猜你喜欢
      • 2021-10-19
      • 2021-11-26
      • 1970-01-01
      • 1970-01-01
      • 2022-12-27
      • 2019-01-27
      • 1970-01-01
      • 1970-01-01
      • 2018-07-10
      相关资源
      最近更新 更多