Java 9弃用了六个包含Java EE api的模块,它们很快就会被移除:

java。使用javax激活。激活包 java。Corba和javax。活动,javax。rmi, javax.rmi。CORBA和org.omg。*包 java。使用javax的事务。交易方案 Java.xml.bind与所有javax.xml.bind。*包 Java.xml.ws和javax。jw, javax.jws。肥皂,javax.xml。Soap和所有javax.xml.ws。*包 Java.xml.ws.annotation。注释包

哪些维护的第三方构件提供了这些api ?它们提供的api有多好,或者它们必须提供哪些其他功能并不重要——重要的是,它们是这些模块/包的临时替代品吗?

为了更容易地收集知识,我回答了我目前所知道的,并将答案创建了一个社区wiki。我希望人们能扩展它,而不是自己写答案。


在投票结束前:

Yes, there are already some questions on individual modules and an answer to this question would of course duplicate that information. But AFAIK there is no single point to learn about all of these, which I think has a lot of value. Questions asking for library recommendations are usually considered off-topic, because "they tend to attract opinionated answers and spam", but I don't think that applies here. The set of valid libraries is clearly delineated: They have to implement a specific standard. Beyond that nothing else matters, so I don't see much risk for opinion and spam.


当前回答

jaxws-ri似乎传递依赖于commonj.sdo:commonj.sdo:jar:2.1.1。V201112051852,显然可以从存储库http://download.eclipse.org/rt/eclipselink/maven.repo中找到

其他回答

只是对上面的答案进行了微小的修改(改进)——这里的示例仅针对JAXB。我们可以在运行时范围内添加依赖项,并且只有在有效需要时才可以这样做(例如,当构建运行在版本>= 9的JRE中时——这里以v11为例):

<profile>
        <id>when-on-jdk-11</id>
        <activation>
            <jdk>11</jdk>
        </activation>

        <properties>
            <!-- missing artefacts version properties -->
            <jaxb-api.version>2.3.1</jaxb-api.version>
            <jaxb-impl.version>2.3.2</jaxb-impl.version> <!-- one might let it the same with the jaxb-api.version -->
        </properties>

        <dependencies>
            <!-- runtime dependencies to avoid JAXB related CNF exceptions when running on Java 11 (e.g.: ClassNotFoundException: javax.xml.bind.annotation.XmlType) -->
            <dependency>
                <groupId>javax.xml.bind</groupId>
                <artifactId>jaxb-api</artifactId>
                <version>${jaxb-api.version}</version>
                <scope>runtime</scope>
            </dependency>
            <dependency>
                <groupId>org.glassfish.jaxb</groupId>
                <artifactId>jaxb-runtime</artifactId>
                <version>${jaxb-impl.version}</version>
                <scope>runtime</scope>
            </dependency>
        </dependencies>
    </profile>

我发现绕过这些问题的JAXB部分的最简单的方法是在我的根pom或bom中使用依赖管理:

    <project ...>
      <dependencyManagement>
        <dependencies>
          <!-- ... -->
          <!-- Gone from jvm in java11 -->
          <dependency>
          <groupId>com.sun.xml.bind</groupId>
          <artifactId>jaxb-ri</artifactId>
          <version>2.4.0-b180830.0438</version>
          <scope>import</scope>
          <type>pom</type>
        </dependency>
        <!-- ... -->
      </dependencies>
    </dependencyManagement>
    </project>

在jdk11上编译失败的模块中:

    <!-- ... -->
    <dependencies>
      <!-- Gone from jvm in java11 -->
      <dependency>
         <groupId>javax.xml.bind</groupId>
         <artifactId>jaxb-api</artifactId>
      </dependency>
      <dependency>
         <groupId>com.sun.xml.bind</groupId>
         <artifactId>jaxb-impl</artifactId>
         <scope>runtime</scope>
      </dependency>
      <dependency>
         <groupId>org.glassfish.jaxb</groupId>
         <artifactId>jaxb-runtime</artifactId>
         <scope>runtime</scope>
      </dependency>
      <!-- ... -->
    </dependencies>  
    <!-- ... -->

另外,更新org.jvnet.jaxb2的版本。Maven2:maven-jaxb2-plugin到0.14.0为我解决了jaxb生成的所有问题。

我在我的spring mvc项目中使用jdk 11 + ant + ivy。 我得到错误的包javax。所以我添加了javax.jws-api-1.1.jar到类路径,它工作了! 只需从https://repo1.maven.org/maven2/javax/jws/javax.jws-api/1.1/javax.jws-api-1.1.jar下载罐子 并将其添加到build.xml中的类路径中

或者将其添加到pom.xml中:

<dependency>
  <groupId>javax.jws</groupId>
  <artifactId>javax.jws-api</artifactId>
  <version>1.1</version>
</dependency>

我需要为基于Spring Boot 2的应用程序替换JAX-WS (java.xml.ws)和JAXB (java.xml.bind),最终得到了这些jar (Gradle构建):

// replacements for deprecated JDK module java.xml.ws
runtimeOnly 'javax.xml.ws:jaxws-api:2.3.0' // javax.xml.ws.* classes
runtimeOnly 'javax.jws:jsr181-api:1.0-MR1' // for javax.jws.* classes

// replacement for deprecated JDK module java.xml.bind
runtimeOnly 'javax.xml.bind:jaxb-api'
runtimeOnly 'org.glassfish.jaxb:jaxb-runtime:2.3.0.1'
runtimeOnly 'org.glassfish:javax.json:1.1.2'
runtimeOnly 'org.eclipse:yasson:1.0.1'

(你可能需要编译或其他范围,runtimeOnly对我们来说就足够了。)

我注意到https://mvnrepository.com/artifact/com.sun.xml.bind/jaxb-core被描述为“旧的”,用这个答案去找org。基于Glassfish的东西也带来了org.eclipse.yasson。

现在的情况真的很混乱,它是有效的,但是人们怎么能确定它是最好的替代品,对吧?

jaxws-ri似乎传递依赖于commonj.sdo:commonj.sdo:jar:2.1.1。V201112051852,显然可以从存储库http://download.eclipse.org/rt/eclipselink/maven.repo中找到