hibernate auto创造了春天的工作

时间:2011-12-30 14:45:41

标签: hibernate spring spring-mvc

您好我有奇怪的问题。我配置了spring + hibernate。我正在使用注释配置,但是当我启动/重新发布/重新启动服务器时,hibernate不想创建我的数据库结构:(

这是我从root-context.xml

的配置
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">

<!-- Root Context: defines shared resources visible to all other web components -->

<!-- Datasource configration -->
<bean id="luxpolDataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
    <property name="driverClassName" value="com.mysql.jdbc.Driver" />
    <property name="url" value="jdbc:mysql://localhost:3306/luxpol" />
    <property name="username" value="user" />
    <property name="password" value="pass" />
</bean>

<bean id="hibernateSessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
    <property name="dataSource" ref="luxpolDataSource" />
    <property name="packagesToScan" value="com.fixus.luxpol.bean" />
    <property name="annotatedClasses">
        <list>
            <value>com.fixus.luxpol.bean.House</value>
            <value>com.fixus.luxpol.bean.Photo</value>
        </list>
    </property>
    <property name="hibernateProperties">
        <props>                         
            <prop key="hibernate.dialect">org.hibernate.dialect.MySQLInnoDBDialect</prop>
            <prop key="hibernate.format_sql">true</prop>
            <prop key="hibernate.show_sql">true</prop>
            <prop key="hibernate.hbm2dll.auto">create</prop>
        </props>
    </property>
</bean>

<mvc:annotation-driven />
<context:component-scan base-package="com.fixus.luxpol" />
<context:component-scan base-package="com.fixus.luxpol.bean" />

我不知道出了什么问题:/

1 个答案:

答案 0 :(得分:1)

该属性名为hbm2ddl.auto,而不是hbm2dll.auto。 DDL表示数据定义语言。 DLL表示动态链接库