SSH框架自动生成数据库

来源:互联网 发布:blend4web 乳品厂源码 编辑:程序博客网 时间:2024/05/17 03:30

自动生成数据库:方法一:

package com.test;


import org.hibernate.cfg.Configuration;
import org.hibernate.tool.hbm2ddl.SchemaExport;

public class TestHinernate {


public static void main(String[] args) {

SchemaExport export = new SchemaExport(new Configuration().configure());


export.create(true, true);
}


}

方法二:

private ApplicationContext ac = new ClassPathXmlApplicationContext("applicationContext.xml");
@Test
public void testSessionFactory() throws Exception{
SessionFactory sessionFactory = (SessionFactory) ac.getBean("sessionFactory");
System.out.println(sessionFactory);
}

0 0
原创粉丝点击