JDK 9的Hibernate 5问题 [英] Hibernate 5 issue with JDK 9

查看:113
本文介绍了JDK 9的Hibernate 5问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Hibernate 5项目,可以在Java 8上完美地构建和运行。我试图在JDK 9 ea build 171上测试它。
由于它是一个庞大的项目并且有其他依赖项,所以我必须添加<$

 < c $ c><插件> 
< groupId> org.apache.maven.plugins< / groupId>
< artifactId> maven-surefire-plugin< / artifactId>
< version> 2.20< / version>
<配置>
< argLine> - add-modules java.xml.bind< / argLine>
< / configuration>
< / plugin>

还有其他问题可以解决,但如果使用聚合模块java.se.ee ):

 < argLine>  -  add-modules java.se.ee< / argLine> 

我收到一个异常:

<$ p $ java.lang.NoClassDefFoundError:javax / transaction / SystemException在java.base / java.lang.Class.forName0中的
(本地方法)$ b $在java.base / java中。 lang.Class.forName(Class.java:374)
at org.jboss.logging.Logger $ 1.run(Logger.java:2554)
位于java.base / java.security.AccessController.doPrivileged (本地方法)
at org.jboss.logging.Logger.getMessageLogger(Logger.java:2529)

我甚至不明白为什么会发生这种情况,因为JTA库( SystemException class)在测试运行时位于类路径中。



关于如何解决这个问题的任何建议?

解决方案

没有回答,并且自JDK的GA版本完成。根据迁移指南和java文档,因为模块 javax.transaction 的nofollow noreferrer> java.transaction 标记为 @Deprecated

理想情况下,您应该将代码迁移到使用而不是javaee / javax.transaction 。目前,您可以使用从依赖关系转换来的自动模块完成此操作:

 < dependency> 
< groupId> javax.transaction< / groupId>
< artifactId> javax.transaction-api< / artifactId>
< version> 1.2< / version>
< /依赖关系>

并添加到 module-info.java 以下内容: -

 需要javax.transaction.api; 






编辑 :感谢 to @ImpulseTheFox a>用于验证上述jar版本1.3的自动模块名称是否需要: -

pre $ 需要java.transaction;


I have a Hibernate 5 project that perfectly builds and runs on Java 8. I tried to test it on JDK 9 ea build 171. Since it is a huge project and have other dependencies I had to add java.xml.bind module to the JVM configuration for tests:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-surefire-plugin</artifactId>
    <version>2.20</version>
    <configuration>
        <argLine>--add-modules java.xml.bind</argLine>
    </configuration>
</plugin>

There were other issues that I could resolve but if used aggregated module java.se.ee(as recommended):

<argLine>--add-modules java.se.ee</argLine>

I got an exception :

java.lang.NoClassDefFoundError: javax/transaction/SystemException
    at java.base/java.lang.Class.forName0(Native Method)
    at java.base/java.lang.Class.forName(Class.java:374)
    at org.jboss.logging.Logger$1.run(Logger.java:2554)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at org.jboss.logging.Logger.getMessageLogger(Logger.java:2529)

I couldn't even understand why it happened because JTA library(with SystemException class) is in the class-path when tests were running.

Any suggestions on how to fix this?

解决方案

Though the question seems old, yet unanswered and since the GA release of JDK is completed. According to the migration guide and the java docs, since the module java.transaction which exports the package javax.transaction has been marked as @Deprecated.

You should ideally migrate your code to be using javaee/javax.transaction instead. Currently, you can do so using automatic module converted from the dependency:

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

and adding to the module-info.java the following:-

requires javax.transaction.api;


Edit: Thanks to @ImpulseTheFox for verifying that the automatic module name for the jar version 1.3 above requires:-

requires java.transaction;

这篇关于JDK 9的Hibernate 5问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆