在 Play for Scala 中实现 Hibernate
Implementing Hibernate in Play for Scala
我正在尝试将 Hibernate 集成到 Play for Scala 中。我添加了一个文件 hibernate.cfg.xml
到 conf/META-INF
但显然 Play 找不到它,因为我收到错误:
play.api.http.HttpErrorHandlerExceptions$$anon: Execution
exception[[ConfigurationException: Could not locate cfg.xml resource
[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$$anonfun$apply.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>
将 xml 文件添加到 conf,而不是 conf/META-INF
我正在尝试将 Hibernate 集成到 Play for Scala 中。我添加了一个文件 hibernate.cfg.xml
到 conf/META-INF
但显然 Play 找不到它,因为我收到错误:
play.api.http.HttpErrorHandlerExceptions$$anon: Execution exception[[ConfigurationException: Could not locate cfg.xml resource [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$$anonfun$apply.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>
将 xml 文件添加到 conf,而不是 conf/META-INF