【问题标题】:Java 11 with gradle: must specify an absolute path but is ${tools.jar}带有 gradle 的 Java 11:必须指定绝对路径,但为 ${tools.jar}
【发布时间】:2020-03-06 01:09:23
【问题描述】:

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

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")

我可以运行该项目,但是 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

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

java.lang.NoClassDefFoundError: javax/xml/bind/Unmarshaller$Listener

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

【问题讨论】:

  • 我建议您在此处查找正在使用的库的更新版本及其发行说明,以便与更高的 java 版本兼容。
  • 是的,我刚刚解决了这个问题。 2.3.0 不再使用 tools.jar。

标签: gradle jaxb build.gradle java-11


【解决方案1】:

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

【讨论】:

  • 我对 jaxb 2.3.1 有同样的问题(spring-boot 提供的依赖关系)。
  • 那可以用哪一个呢?
猜你喜欢
  • 1970-01-01
  • 2014-02-28
  • 2015-01-14
  • 2016-03-16
  • 2016-09-29
  • 1970-01-01
  • 2022-12-15
  • 2018-02-04
  • 1970-01-01
相关资源
最近更新 更多