在Scala中为Play实现Hibernate

时间:2017-07-21 17:58:15

标签: scala hibernate playframework playframework-2.0

我试图在Play for Scala中集成Hibernate。我向hibernate.cfg.xml添加了一个文件conf/META-INF,但是当我收到错误时,Play似乎找不到它:

  

play.api.http.HttpErrorHandlerExceptions $$ anon $ 1:执行   exception [[ConfigurationException:找不到cfg.xml资源   [hibernate.cfg.xml中]]]           at play.api.http.HttpErrorHandlerExceptions $ .throwableToUsefulException(HttpErrorHandler.scala:293)           at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:220)           at play.api.GlobalSettings $ class.onError(GlobalSettings.scala:160)           at play.api.DefaultGlobal $ .onError(GlobalSettings.scala:188)           at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:100)           at play.core.server.netty.PlayRequestHandler $$ anonfun $ 2 $$ anonfun $ apply $ 1.applyOrElse(PlayRequestHandler.scala:100)

这是hibernate.cfg.xml文件,我应该把它放在哪里?

<?xml version='1.0' encoding='utf-8'?>
<!DOCTYPE hibernate-configuration PUBLIC
    "-//Hibernate/Hibernate Configuration DTD//EN"
    "http://www.hibernate.org/dtd/hibernate-configuration-3.0.dtd">

<hibernate-configuration>
  <session-factory>
    <property name="hibernate.connection.driver_class">com.sap.db.jdbc.Driver</property>
    <property name="hibernate.connection.url">jdbc:sap://10.194.19.20:39013</property>
    <property name="hibernate.connection.username">uuu</property>
    <property name="hibernate.connection.password">xxx</property>
    <property name="hibernate.dialect">org.hibernate.dialect.HANAColumnStoreDialect</property>
  </session-factory>
</hibernate-configuration>

1 个答案:

答案 0 :(得分:1)

将xml文件添加到conf,而不是conf / META-INF