我遇到了hibernate的问题。问题:使用名称' emf'创建bean时出错在ServletContext资源中定义[/WEB-INF/spring/appServlet/servlet-context.xml]:调用init方法失败;嵌套异常是java.lang.NoSuchMethodError:org.hibernate.cfg.Environment.verifyProperties(Ljava / util / Map;)V
它的xml文件(servlet-context):http://pastebin.com/BRYvbVTg
而且,我只有一个来自hibernate的依赖:
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>5.2.4.Final</version>
</dependency>
在classpath中,尝试添加所有包,具有相同的效果
完整堆栈跟踪:http://pastebin.com/wJy7QfPW
答案 0 :(得分:1)
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter" />
</property>
<property name="jpaProperties">
<props>
<prop key="hibernate.hbm2ddl.auto">update</prop>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.connection.charSet">UTF-8</prop>
<prop key="hibernate.show_sql">true</prop>
</props>
</property>
<property name="packagesToScan" value="ru.mrchebik.model"/>
我希望这有帮助!