带有 gradle 的 Java 11:必须指定一个绝对路径,但它是 ${tools.jar}

Ara*_*nSG 3 jaxb gradle build.gradle java-11

我们正在使用 jaxb 的项目从 Java 8 迁移到 11。由于它已从 JDK 中删除,因此必须单独包含,这是我通过 gradle 配置完成的:

compile("javax.xml.bind:jaxb-api:2.2.11")
compile("com.sun.xml.bind:jaxb-core:2.2.11")
compile("com.sun.xml.bind:jaxb-impl:2.2.11")
Run Code Online (Sandbox Code Playgroud)

我能够运行该项目,但是 compileJava gradle 作业会引发错误:

Errors occurred while build effective model from C:\Users\.\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-core\2.2.11\db0f76866c6b1e50084e03ee8cf9ce6b19becdb3\jaxb-core-2.2.11.pom:
'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in com.sun.xml.bind:jaxb-core:2.2.11
Errors occurred while build effective model from C:\Users\.\.gradle\caches\modules-2\files-2.1\com.sun.xml.bind\jaxb-impl\2.2.11\2d4b554997fd01d1a2233b1529b22fc9ecc0cf5c\jaxb-impl-2.2.11.pom:
'dependencyManagement.dependencies.dependency.systemPath' for com.sun:tools:jar must specify an absolute path but is ${tools.jar} in com.sun.xml.bind:jaxb-impl:2.2.11
Run Code Online (Sandbox Code Playgroud)

作业完成并创建了一个 jar,但是在生产服务器上运行时,它会因以下错误而停止:

java.lang.NoClassDefFoundError: javax/xml/bind/Unmarshaller$Listener
Run Code Online (Sandbox Code Playgroud)

我正在使用 Spring Boot v1.5.6 和 gradle 4.8.1

Ara*_*nSG 8

解决方案是使用较新版本的 jaxb 库。2.3.0 不再使用 tools.jar。