急求:Sturts2 + spring + hibernate写的能自动创建表的 请给的详细一些
谢谢谢谢
[color=blue][b]如果不是以JPA的方式使用的话,这样试试:[/b][/color]
[code="xml"]
cn/itcast/bean/Employee.hbm.xml
hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
hibernate.hbm2ddl.auto=update
hibernate.show_sql=false
hibernate.format_sql=false
[/code]
[color=blue][b]
我的这两种写法都是 JPA的方式使用Hibernate
方法一:在persistence.xml中配置:[/b][/color]
[code="xml"]
[/code]
[color=blue][b]
方法二: 配合EntityManagerFactory时,加入jpaProperties属性[/b][/color]
[code="xml"] class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="database" value="MYSQL" />
<property name="showSql" value="true" />
<property name="generateDdl" value="true"></property>
</bean>
</property>
<property name="jpaProperties">
<props>
<prop key="hbm2ddl.auto">create</prop>
</props>
</property>
</bean>[/code]
[b]
将上述的 hbm2ddl.auto的值 改为你想要的类型[/b]