HTTP状态500-请求处理失败;嵌套异常是org.hibernate.exception.sqlgrammareexception:Table';rbcart.product';不';不存在

HTTP状态500-请求处理失败;嵌套异常是org.hibernate.exception.sqlgrammareexception:Table';rbcart.product';不';不存在,hibernate,spring-mvc,jpa,Hibernate,Spring Mvc,Jpa,我正在创建一个应用程序,每当我单击产品选项卡时,它都会列出数据库中的所有产品。下面是文件 <?xml version="1.0" encoding="utf-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframewo

我正在创建一个应用程序,每当我单击产品选项卡时,它都会列出数据库中的所有产品。下面是文件

<?xml version="1.0" encoding="utf-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-bean">
    <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
        <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
        <property name="url" value="jdbc:mysql://localhost:3306/rbcart"/>
        <property name="username" value="root"/>
        <property name="password" value="root"/>
    </bean>
    <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource"/>
        <property name="hibernateProperties">
            <props>
                <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
            </props>
        </property>
        <property name="packagesToScan">
            <list>
                <value>com.emusicstore</value>
            </list>
        </property>
    </bean>
    <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory" ref="sessionFactory"/>
    </bean>
</beans>

org.hibernate.dialogue.mysqldialogue
更新
真的
真的
com.emusicstore
所以当我点击产品标签时,它给了我一个错误 HTTP状态500-请求处理失败;嵌套异常为org.hibernate.exception.sqlgrammareexception:表“rbcart.product”不存在


但是hibernate应该自己创建表。那么这有什么不对呢?

我也有同样的问题。我的问题是我将id保存为字符串(在模型类中),并添加了注释@GeneratedValue(strategy=GenerationType.AUTO)。如果我对注释进行了注释,则表是在数据库中创建的,错误不再出现。
希望这有帮助。

也许您没有创建模式。您可以尝试通过添加“?createDatabaseIfNotExist=true”来修改url,如下所示:

您是否可以偶然将您的
产品
实体映射包括在内?如果直接查询数据库,是否可以看到该数据库中的表?不,数据库中没有表。Hibernate应该正确创建数据库吗?我使用注释来实现这一点,所以不需要xml映射,对吗?在产品类中,我为类指定了@Entity。