Configuration config = new Configuration().configure(); 一直报空指针异常
//1.创建一个配置对象
Configuration config = new Configuration().configure();
//2.创建服务注册对象
// ServiceRegistry serviceRegistry =new
// ServiceRegistryBuilder().applySettings(config.getProperties()).build();
StandardServiceRegistryBuilder ssrb = new
StandardServiceRegistryBuilder().applySettings(config.getProperties());
StandardServiceRegistry ssr = ssrb.build();
//3.创建sessionFactory 会话工厂
SessionFactory sf = config.buildSessionFactory(ssr);
Session session =sf.getCurrentSession();
//创建SchemaExport 生成表结构
SchemaExport export =new SchemaExport(config);
export.create(true, true);
<property name="connection.username">root</property>
<property name="connection.password">123456</property>
<property name="connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="connection.url">jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8</property>
<property name="dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="show_sql">true</property>
<property name="format_sql">true</property>
<property name="hbm2ddl.auto">update</property>
<property name="hibernate.current_session_context_class">thread</property>
<!--对应的映射 -->
<mapping resource="entity/Students.hbm.xml" />
<mapping resource="entity/Users.hbm.xml" />
我实在在不到方法求问慕课的朋友们帮忙一下