hibernate.cfg.xml基础配置
1、hbm2ddl.auto
Automatically validates or exports schema DDL to the database when the
SessionFactory
is created. With create-drop
, the database
schema will be dropped when the SessionFactory
is closed explicitly.
e.g. validate
| update
| create
| create-drop
PS:,企业大多数是先建表,然后再生成实体类(虽然面向对象的设计思想是先建实体类再建表)
<property name="hbm2ddl.auto">create</property>
2、搭建log4j日志环境
slf4j与log4j
的关系:
slf4j
像是一个大管家,可以管理许多的日志框架,
log4j
是其中之一。
hibernate.cfg.xml基础配置
①添加实现了slf4j-api的log4j.jar
②添加将slf4j的接口转换为log4j的接口的jar包(这样的设计模式是适配器)
③在src下配置log4j.properties