I can’t connect my config file, it gives an error, I tried these methods org.hibernate.internal.util.config.ConfigurationException: Could not locate cfg.xml resource [/HibernateTest/src/hibernate.cfg.xml]
but they don’t work
This is my code
SessionFactory sessionFactory = new Configuration()
.configure("./hibernate.cfg.xml")
.addAnnotatedClass(Employee.class)
.buildSessionFactory();
try {
Session session = sessionFactory.getCurrentSession();
Employee employee = new Employee("Marsel", "Charginov", "IT", 500);
session.beginTransaction();
session.save(employee);
session.getTransaction().commit();
}finally {
sessionFactory.close();
}
This is my error
февр. 21, 2022 11:07:56 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate ORM core version 5.6.3.Final
Exception in thread "main" org.hibernate.internal.util.config.ConfigurationException: Could
not locate cfg.xml resource [./hibernate.cfg.xml]
This is my file structure
- src
- main
- java
- hibernate
- Main.java
- entity
- Employee.java
- entity
- Main.java
- hibernate
- java
- resources
- hibernate.cfg.xml
- main