如何使用這些配置在我的專案中找到默認Hibernate版本的確切版本:
- Java EE 8
- Java版本“17”
- Apache-Maven-3.8.2
- Eclipse 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>
我也檢查了這個鏈接,但對我沒有幫助:LINK
甚至這個代碼片段也有錯誤:
System.out.println(org.hibernate.annotations.common.Version.VERSION);
org.hibernate 無法決議為變數
uj5u.com熱心網友回復:
您使用的不是 Hibernate,而是 JPA。休眠版本在 WildFly pom.xml https://github.com/wildfly/wildfly/blob/26.1.0.Final/pom.xml#L418 for WildFly 26.1.0.Final 中設定
uj5u.com熱心網友回復:
嘗試
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();
}
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/476389.html
