【发布时间】:2022-02-08 14:12:42
【问题描述】:
我正在使用 Maven,在 Netbeans 上,在 Windows 上
我有完整配置的 hibernate.cfg.xml 文件 "/src/main/resources/hibernate.cfg.xml"
我已经三重确认这是一个事实。 This is my folder structure on Netbeans (picture)
运行时我得到这个:
Exception in thread "main" org.hibernate.internal.util.config.ConfigurationException:
Could not locate cfg.xml resource [/resources/hibernate.cfg.xml]
这是我的休眠 cfg.xml 文件:
<!-- This file should be referenced in the configure() method!!! -->
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<! -- url -->
<property name="hibernate.connection.url">jdbc:oracle:thin:@toshiba-pc:1521:SYSTEM</property>
<! -- username -->
<property name="hibernate.connection.username">system</property>
<!-- password -->
<property name="hibernate.connection.password">27111995</property>
<!-- database driver -->
<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
</session-factory>
</hibernate-configuration>
在我的主课上,相关行如下:
public static void main(String[] args) {
Configuration cfg = new Configuration();
cfg.configure("/resources/hibernate.cfg.xml");
...more code...
所以基本上我一直在尝试解决这个问题,但完全没有成功。任何帮助将不胜感激。
【问题讨论】:
标签: java hibernate maven netbeans