public class GuardarClientePrueba {
public static void main(String[] args) {
// TODO Auto-generated method stub
SessionFactory miFactory = new Configuration().configure("hibernate.cfg.xml").addAnnotatedClass(Clientes.class).buildSessionFactory();
Session session = miFactory.openSession();
try {
Clientes cliente = new Clientes("Juan", "Perez", "Colonia 1");
session.beginTransaction();
session.save(cliente);
session.getTransaction().commit();
System.out.println("Cliente guardado con éxito");
session.close();
} catch (HibernateException e) {
e.printStackTrace();
} finally {
miFactory.close();
}
}
}
Este error me sale en consola:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/JAXBException
at org.hibernate.boot.spi.XmlMappingBinderAccess.<init>(XmlMappingBinderAccess.java:43)
at org.hibernate.boot.MetadataSources.<init>(MetadataSources.java:87)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:123)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:118)
at es.pildoras.conexionHibernate.GuardarClientePrueba.main(GuardarClientePrueba.java:16)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.JAXBException
at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:583)
at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
... 5 more