繁体   English   中英

使用JDK 1.6时,我的网络应用程序中是否需要stax-api-1.0.x?

[英]Do I need stax-api-1.0.x in my web app when using JDK 1.6?

我目前正在开发一个使用Jersey for REST的Web应用程序。 我使用maven,并且stax-api-1.0.1和1.0.2都被拉入我的web-inf / lib。 我认为stax api是JDK1.6的aprt?

为什么这些JARS包含在我的Web应用程序中?

这是我的pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.glennbech</groupId>
    <artifactId>simplerest</artifactId>
    <packaging>war</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>Simplerest Maven Webapp. Very simple REST.</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <!-- Jersey for REST -->
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.9</version>
        </dependency>

        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-json</artifactId>
            <version>1.9</version>
        </dependency>

        <dependency>
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>5.1.17</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>simplerest</finalName>
        <plugins>
            <plugin>
                <groupId>org.mortbay.jetty</groupId>
                <artifactId>maven-jetty-plugin</artifactId>
                <version>6.1.25</version>
                <configuration>
                    <contextPath>/</contextPath>
                    <scanIntervalSeconds>5</scanIntervalSeconds>
                </configuration>
            </plugin>
        </plugins>

</build>

这个问题在问题的评论栏中得到了回答。 感谢Paul Grime。

stax确实包含在Java 1.6中,但是Maven并不知道您正在将应用程序部署到Java 1.6运行时。 您的依赖项也不知道您正在使用的运行时。 事实上,他们可能已经专门编写自己的Java 1.5甚至更早版本。

是的,[使用maven排除修复它]将是IMO最简单的解决方案。 下一步可能是为不同的目标运行时创建不同的配置文件。 例如,“1.6”配置文件将排除stax等,但“1.5”配置文件将保留它们。

<dependency>
  <groupId>the.thing.that</groupId>
  <artifactId>transitively-imports</artifactId>
  <version>the.stax.version</version>
  <exclusions>
    <!--  STAX comes with Java 1.6 -->
    <exclusion>
        <artifactId>stax-api</artifactId>
        <groupId>javax.xml.stream</groupId>
    </exclusion>
    <exclusion>
        <artifactId>stax-api</artifactId>
        <groupId>stax</groupId>
    </exclusion>
  </exclusions>
<dependency>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM