日期:2014-05-17  浏览次数:20685 次

不能自动生成数据库表
下面是spring的bean.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:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
           http://www.springframework.org/schema/context
           http://www.springframework.org/schema/context/spring-context-2.5.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-2.5.xsd">
           
 <context:annotation-config />
 <context:component-scan base-package="com.message.*" />

<!-- 连接数据库 -->
<bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close" >
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="jdbc:mysql://localhost/ssh" />
<property name="username" value="root" />
<property name="password" value="root" />
</bean>

<!-- SessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- <property name="packagesToScan" value="com.message.entity"></property> -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hbm2ddl.auto">update</prop>
</props>
</property>
 <property name="annotatedClasses">  
        <list>  
            <value>com.message.entity.User</value>  
            <value>com.message.entity.DeletedMessage</value>
            <value>com.message.entity.Group</value>
            <value>com.message.entity.ReceiveMessage</value>
            <value>com.message.entity.SendMessage</value>
        </list>  
    </property>  

</bean>

  </beans>
mysql 数据库 spring bean