Java EE 8 / JSF-2.3 / Wildfly-26项目中使用的Hibernate的默认版本

发布于 2025-01-29 11:12:29 字数 2360 浏览 4 评论 0 原文

我如何在我的项目中使用以下配置找到默认 Hibernate 版本的精确版本:

  • Java EE 8
  • Java版本“ 17”
  • Apache-Maven-3.8.2
  • Eclipse IDE IDE版本:2022-03(4.23.0) )
  • wildfly-26.1.0.final

pom.xml 文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>example</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>8.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>2.1.212</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.3.2</version>
            </plugin>
        </plugins>
    </build>
</project>

我还检查了此链接,但没有帮助我:链接

,甚至此代码片段都有错误:

System.out.println(org.hibernate.annotations.common.Version.VERSION);

org.hibernate不能解决变量

How can I find exact version of default Hibernate version in my project with these configs:

  • Java EE 8
  • Java version "17"
  • Apache-Maven-3.8.2
  • Eclipse IDE Version: 2022-03 (4.23.0)
  • Wildfly-26.1.0.Final

pom.xml file:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.example</groupId>
    <artifactId>example</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <packaging>war</packaging>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
        <maven.compiler.source>17</maven.compiler.source>
        <maven.compiler.target>17</maven.compiler.target>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>8.0</version>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <version>2.1.212</version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-war-plugin</artifactId>
                <version>3.3.2</version>
            </plugin>
        </plugins>
    </build>
</project>

I also check this link but does not help me: LINK

And even this code snippet has error:

System.out.println(org.hibernate.annotations.common.Version.VERSION);

org.hibernate cannot be resolved to a variable

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

孤独岁月 2025-02-05 11:12:29

您不是使用冬眠,而是使用JPA。 Hibernate版本设置为wildfly pom.xml for Wildfly 26.1.0.final

You are not using Hibernate but JPA. The hibernate version is set in the WildFly pom.xml https://github.com/wildfly/wildfly/blob/26.1.0.Final/pom.xml#L418 for WildFly 26.1.0.Final

南城旧梦 2025-02-05 11:12:29

尝试

System.out.println(org.hibernate.Version.getVersionString());

package com.test;
public class TestBean {
public static void main(String[] args) {
    try {
        String hibernateVersion = org.hibernate.annotations.common.Version.VERSION;
        System.out.println("Hibernate Version: "+ hibernateVersion);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
}

Try

System.out.println(org.hibernate.Version.getVersionString());

or

package com.test;
public class TestBean {
public static void main(String[] args) {
    try {
        String hibernateVersion = org.hibernate.annotations.common.Version.VERSION;
        System.out.println("Hibernate Version: "+ hibernateVersion);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文