Spring3 + Hibernate4 报错

hoodlake 发布于 2015/03/14 22:36
阅读 711
收藏 0

【开源中国 APP 全新上线】“动弹” 回归、集成大模型对话、畅读技术报告”

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/spring/applicationContext-hibernate.xml]: Invocation of init method failed; nested exception is org.hibernate.HibernateException: Access to DialectResolutionInfo cannot be null when 'hibernate.dialect' not set

方言是有配置的:


<bean id="sessionFactory"
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"/>
<property name="hibernateProperties">
<props>
<prop key="hiberante.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.format_sql">true</prop> 
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.cache.use_second_level_cache">false</prop>
<prop key="hibernate.cache.use_query_cache">false</prop>
<prop key="hibernate.jdbc.fetch_size">50</prop>
<prop key="hibernate.jdbc.batch_size">50</prop>
           <prop key="hibernate.connection.autocommit">true</prop>
           <prop key="hibernate.connection.release_mode">auto</prop>
           <prop key="javax.persistence.validation.mode">none</prop>
<prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</prop>
</props>
</property>
<property name="packagesToScan">
<!-- 多个包用逗号分割 -->
<value>com.zz.wechat.persistence</value>
</property>
</bean>


说是sessionFactory的获取方式发生变化了,具体该怎么做呢?官方文档里也是狗屁的都没有说明 


加载中
0
hoodlake
hoodlake
多谢关注,我换了种写法就OK了:
<property name="hibernateProperties">
<value>
                <!-- 设置数据库方言 -->
                hibernate.dialect=org.hibernate.dialect.MySQLDialect
                <!-- 设置自动创建|更新|验证数据库表结构 -->
                hibernate.hbm2ddl.auto=update
                <!-- 是否在控制台显示sql -->
                hibernate.show_sql=true
                <!-- 是否格式化sql,优化显示 -->
                hibernate.format_sql=true
                <!-- 是否开启二级缓存 -->
                hibernate.cache.use_second_level_cache=false
                <!-- 是否开启查询缓存 -->
                hibernate.cache.use_query_cache=false
                <!-- 数据库批量查询最大数 -->
                hibernate.jdbc.fetch_size=50
                <!-- 数据库批量更新、添加、删除操作最大数 -->
                hibernate.jdbc.batch_size=50
                <!-- 是否自动提交事务 -->
                hibernate.connection.autocommit=true
                <!-- 指定hibernate在何时释放JDBC连接 -->
                hibernate.connection.release_mode=auto
                <!-- 创建session方式 hibernate4.x 的方式 -->
                hibernate.current_session_context_class=org.springframework.orm.hibernate4.SpringSessionContext
                <!-- javax.persistence.validation.mode默认情况下是auto的,就是说如果不设置的话它是会自动去你的classpath下面找一个bean-validation**包所以把它设置为none即可 -->
                javax.persistence.validation.mode=none
            </value>
</property>




0
甘薯
甘薯

亲, www.baidu.com

http://demo.netfoucs.com/sinat_19425927/article/details/39855045 这里有一篇不知道是否适用

不知道你英文如何, 这里也有

http://www.tuicool.com/articles/7FZrYzE

请先运用板砖工具...

OSCHINA
登录后可查看更多优质内容
返回顶部
顶部