gpt4 book ai didi

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

转载 作者:搜寻专家 更新时间:2023-10-30 21:27:02 24 4
gpt4 key购买 nike

我目前正在开发一个使用 Jersey for REST 的网络应用程序。我使用 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 does come included in Java 1.6, but Maven does not know you are deploying your app to a Java 1.6 runtime. Nor do your dependencies know what runtime you are using. In fact, they may have been specifically written themselves to work with Java 1.5 or even earlier.

Yeah, [fixing it using maven exclusions] would be the easiest solution IMO. A next step could be to create different profiles for different target runtimes. E.g. a "1.6" profile would exclude stax etc, but a "1.5" profile would leave them in.

关于java - 使用 JDK 1.6 时,我的 Web 应用程序中是否需要 stax-api-1.0.x?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7374048/

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