我想知道是否有人熟悉stax2,尤其是stax2-api。
我的申请中有一种奇怪的行为。
我有一个依赖于Java.xml.stream的应用程序A:stax-1.0-2
但是,一旦我将org.codehaus.woodstox:stax2-api放在我的依赖项中,甚至还没有使用它,应用程序就会切换到使用stax2-api。
Stax2-api在github上介绍如下:
Stax2是通过以下Stax2实现来实现的: 此外,Stax2 API包含包装器实现,可用于支持常规Stax实现上的大多数API,如SJSXP (与JDK1.6和1.7捆绑的默认Stax实现)。
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。
发布于 2016-04-01 00:46:30
这个问题没有任何意义:stax2-api只是一个实现可能选择实现的API扩展。它对任何其他事物都没有权力,也不自动注册任何东西。
您可能拥有的是,在类路径中包含任何Stax实现将导致添加SPI (META/services/),这可能会改变加载的实际Stax实现,除非您指定所需的实现(比如调用XMLInputFactory.newFactory()时)。但这与Stax2 API无关。
https://stackoverflow.com/questions/32402692
复制相似问题