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

假如想象 提交于 2019-12-03 11:50:43
Bill the Lizard

This question was answered in the comment field of the question. Kudos to 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.

<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>
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!