Modules jta and java.sql export package javax.transaction.xa to module dom4j
如您所见,jta
和java.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. Moreoverjavax.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 thejava.sql
module in Java SE 9. Because thejava.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/