如何为JDK编写GitHub工作流程17
这是JDK 11的当前GitHub,正常工作。我已经将项目迁移到JDK 17。它在本地工作正常,但在GitHub工作流程中断裂。我不知道该如何解决?
。
name: Docker
on:
push:
branches: [ master ]
# Publish semver tags as releases.
tags: [ 'v*.*.*' ]
pull_request:
branches: [ master ]
env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}
TAG: 'latest'
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
# This is used to complete the identity challenge
# with sigstore/fulcio when running outside of PRs.
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: maven-settings-xml-action
uses: whelk-io/maven-settings-xml-action@v12
with:
repositories: '[{ "id": "github", "name": "Backend repo", "url": "https://maven.pkg.github.com/dcsaorg/Core", "releases": { "enabled": "true" }, "snapshots": { "enabled": "true" } }]'
servers: '[{ "id": "github", "username": "${{ secrets.USER }}", "password": "${{ secrets.PACKAGES_PAT }}" }]'
- name: Checkout org/TNT
uses: actions/checkout@v2
with:
repository: org/TNT
ref: master
token: ${{ secrets.REPO_ACCESS_PAT }}
path: TNT
- name: Build TNT
run: cd TNT && mvn install -DskipTests -X
- name: build Toolkit
run: mvn -B package -DskipTests -X
- name: Extract Build tag
id: buildtag
run: echo "TAG=$(mvn org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -q -DforceStdout)">> $GITHUB_ENV
# Build and push Docker image
# https://github.com/marketplace/actions/docker-build-push-action
- name: Build and push Docker image
uses: mr-smithers-excellent/docker-build-push@v5
with:
image: consumer
tags: ${{ env.TAG }}, latest
registry: ghcr.io
githubOrg: org
username: ${{ github.actor }}
password: ${{ secrets.USER_PACKAGES_PAT }}
FROM eclipse-temurin:17-jre-alpine
RUN mkdir -p /ctk
COPY target/ctk_consumer-*.jar /ctk/ctk_consumer.jar
WORKDIR /ctk/
ENTRYPOINT java -jar ctk_consumer.jar
致命错误编译:错误:无效目标发布:17-&GT; [help 1]
建议之后更新了pom.xml: -
<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.10.1</version>
<configuration>
<source>17</source>
<target>17</target>
<annotationProcessorPaths>
<path>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct-processor</artifactId>
<version>${mapstruct.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</path>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok-mapstruct-binding</artifactId>
<version>0.2.0</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
</plugins>
</build>
更新完整的pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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.4.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>org.company</groupId>
<artifactId>ctk_consumer</artifactId>
<version>0.0.2</version>
<packaging>jar</packaging>
<name>ctk_consumer</name>
<description>ctk consumer</description>
<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<java.version>17</java.version>
<dcsa.tnt.version>0.0.1</dcsa.tnt.version>
<dcsa.artifacttype>-SNAPSHOT</dcsa.artifacttype>
<lombok.version>1.18.22</lombok.version>
</properties>
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>4.0.1</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.1.0</version>
</dependency>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.13</version>
</dependency>
<dependency>
<groupId>com.aventstack</groupId>
<artifactId>extentreports</artifactId>
<version>5.0.9</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在使用Maven编译器插件3.8.1版,该版本于2019年5月发布,该版本于2021年9月发布,该版本是Java 17。在
pom.xml
中。或这样:
来源: https ://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
您也没有在工作流程中指定Java版本,指定它:
否则,您正在使用所使用的GitHub Runner中的任何Java版本是默认版本,并且由于您不固定版本而不是使用Ubuntu:最新,这可能不是您想要的,甚至是您想要的,甚至是随着时间的变化。
You are using Maven compiler plugin version 3.8.1, which was released in May 2019 for Java 17, which was released in September 2021. Make sure that you use the newest Maven Compiler plugin and that you specify the correct Java release in its configuration setting in
pom.xml
.Or like this:
Source: https://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html
You also don't specify the Java version in your workflow, the GitHub actions Maven starter workflow specifies it like this:
Otherwise you are using whatever Java version is the default in the GitHub runner you are using and as you are not pinning down the version but instead use ubuntu:latest, this may not be the one you want and even change over time.