我可以从 Java 模块中排除导出的包吗?
Can I exclude an exported package from a Java module?
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 reads the following in confirmation to what @Alan already pointed out in a -
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>
此外 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.
您可以使用 javac -d -cp /PATHTOYOURFILE
-d
和 -cp
标志来仅编译所需的目录和类路径。类路径也可以用逗号分隔。
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 reads the following in confirmation to what @Alan already pointed out in a
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>
此外 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.
您可以使用 javac -d -cp /PATHTOYOURFILE
-d
和 -cp
标志来仅编译所需的目录和类路径。类路径也可以用逗号分隔。