gpt4 book ai didi

java - 使用 stax2-api 的问题

转载 作者:行者123 更新时间:2023-11-30 07:57:58 25 4
gpt4 key购买 nike

我想知道是否有人熟悉 stax-api,特别是 stax2-api。

我的应用程序有一个奇怪的行为。

我有一个依赖于 Java.xml.stream:stax-1.0-2 的应用程序 A

但是,一旦我将 org.codehaus.woodstox:stax2-api 放入我的依赖项中,甚至还没有使用它,应用程序就会切换到使用 stax2-api。

Stax2-api在github上的介绍如下:

Stax2 API is implemented natively by following Stax XML implementations:

Woodstox Aalto In addition, Stax2 API contains wrapper implementations that can be used to support most of API on regular Stax implementations like Sun SJSXP (default Stax implementation bundled with JDK 1.6 and 1.7).

API 类位于包 org.codehaus.stax2 中。

Stax2 API also contains partial Reference Implementation of many of API classes, under org.codehaus.stax2.ri: intention is to make it as painless as possible for Java Stax parser to implement full Stax2 support.

<dependency>
<groupId>org.codehaus.woodstox</groupId>
<artifactId>stax2-api</artifactId>
<version>3.1.2</version>
</dependency>

stax2的依赖如下:

    <dependencies>
<!-- Since baseline with 4.0 is Java5, we still need to officially keep this in;
should drop once we go up to Java6 or 7
-->
<dependency>
<groupId>javax.xml.stream</groupId>
<artifactId>stax-api</artifactId>
<version>1.0-2</version>
<!-- at this point, with inclusion in JDK 1.6, this should be given -->
<scope>provided</scope>
</dependency>
</dependencies>

应该指出的是,我的应用程序 A 在其对 Java.xml.stream:stax-1.0-2 的原始依赖项下运行良好。

知道为什么使用 stax2 而不是 stax。

最佳答案

这个问题没有任何意义:stax2-api 只是实现可能选择实现的 API 扩展。它没有权力凌驾于任何其他事物上;不自动注册任何东西。

您可能会遇到的是,在类路径中包含任何 Stax 实现都将导致添加 SPI (META-INF/services/),并且这可能会更改加载的实际 Stax 实现,除非您指定了所需的实现(例如当调用 XMLInputFactory.newFactory())。但这与 Stax2 API jar 无关。

关于java - 使用 stax2-api 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32402692/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com