我正在使用(Maven)依赖项,它本身依赖于xml-apis
。不幸的是,这个包的存在现在会导致我们的 OSGi 环境发生冲突(如果相关,请参见下文)。
查看 JAR 内容,我发现当前 JRE 中似乎存在一些类。所以,我的问题是:排除这种依赖性是否安全?
一般来说:是否有关于曾经是独立依赖项但现在已集成到 JRE 中的类的官方文档?
<小时/>以下是当创建的 xml-apis
包存在时提到的 OSGi 错误:
Bundle was not resolved because of a uses contraint violation.
org.osgi.service.resolver.ResolutionException: Uses constraint violation. Unable to resolve resource my.company.plugin [osgi.identity; osgi.identity="my.company.plugin"; type="osgi.bundle"; version:Version="2.0.0.201707131542"; singleton:="true"] because it is exposed to package 'javax.xml.transform' from resources org.eclipse.osgi [osgi.identity; type="osgi.bundle"; version:Version="3.11.1.v20160708-1632"; osgi.identity="org.eclipse.osgi"; singleton:="true"] and xml-apis [osgi.identity; type="osgi.bundle"; version:Version="1.4.1.bnd-vA0Q7A"; osgi.identity="xml-apis"] via two dependency chains.
最佳答案
您可以将 xml-api 定义为项目的 pom.xml 中的显式依赖项,其范围为“provided”。那么它就不会成为运行时依赖项的一部分。
关于java - xml-apis JAR 文件是否必要?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45085746/