java - 我可以从 Java 模块中排除导出的包吗?

标签 java java-9 jta java-module

Modules jta and java.sql export package javax.transaction.xa to module dom4j

如您所见,jtajava.sql 模块都导出相同的包javax.transaction.xa。但是,jta 中的程序包包含我需要的类,但在 java.sql 中不存在。我根本不需要 java.sql 模块,但我需要 java.sql.SQLException

是否可以阻止java.sql导出javax.transaction.xa

最佳答案

JTA GitHub阅读以下内容以确认@Alan 在 comment 中已经指出的内容-

This standalone release of Java(TM) Java Transaction API (JTA), uses a Java Platform Module System "automatic" module name of java.transaction, to match the module name used in JDK 9. A future version will include full module metadata. Moreover javax.transaction.xa package is now owned by Java SE.

您可以使用 Maven 的版本(例如)使用:-

<dependency>
    <groupId>javax.transaction</groupId>
    <artifactId>javax.transaction-api</artifactId>
    <version>1.3</version>
</dependency>

这是 release notes for JTA1.3MR.


此外 JEP 320: Remove the Java EE and CORBA Modules 对此进行了详细说明 -

... The javax.transaction.xa package supports XA transactions in JDBC. This "XA package" is co-located with JDBC in the java.sql module in Java SE 9. Because the java.sql module is not upgradeable, it is not possible for a standalone version of JTA to override the Java SE version of the XA package

并进一步注意解决方案的可扩展性

...For ease of maintenance, the XA package in Java SE may be moved to a different non-upgradeable module in the future, but as an architectural matter it will remain in Java SE alongside JDBC for the long term...

按照计划

In early 2018, JTA 1.3 will be defined to consist of just the CORBA interop package; the JAR file will be updated accordingly.

关于java - 我可以从 Java 模块中排除导出的包吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51004100/

相关文章:

java - 无法为 Java 9 中自动生成的模块名称派生模块描述符?

ant - 向 ant 启动命令添加长 JVM 选项

java - Maven 可以生成模块声明吗?

java - EclipseLink JTA 持久性问题(空指针异常)

eclipse - Ubuntu 中的 Java 编译器

java - Twilio 通过 ivr 调用回复传入短信

java - Jenkins中的算法协商失败SSH

java - 带有桌面应用程序的 CDI

java - 使用 JPA 更新

java - 无需手动提交的 JTA EntityManager