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

阿拉贡SG

我们正在使用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

阿拉贡SG

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

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章