0
我使用的是Play 1.2.5。我在我的游戏项目中使用了休眠。我在application.conf添加的数据库信息如下Play Framework 1休眠集成
db.driver=com.mysql.jdbc.Driver
db.url=jdbc:mysql://localhost:3306/dbname
db.user=username
db.pass=password
我也有加入如下conf文件夹下的hibernate.cfg.xml的数据库信息,
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.password">password</property>
<property name="hibernate.connection.url">jdbc:mysql://localhost:3306/dbname</property>
<property name="hibernate.connection.username">username</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
我的应用程序是运行正常,但我不确定在两个文件中定义数据库连接是否是一种好的做法。有没有办法在一个地方定义数据库连接。如果我错了,请纠正我。
当你删除hibernate.cfg.xml文件时会发生什么? Play 1在内部管理Hibernate,你基本上不需要任何额外的配置文件。除此之外,请按照手册要求做的事情做,而不是你自己猜测你需要做的事情。 – Gimby
我试图删除hibernate.cfg.xml文件并运行应用程序。我收到以下错误,导致:org.hibernate.HibernateException:找不到/hibernate.cfg.xml。如果我删除这个文件,那么我需要给出映射信息。即模型类的映射 –