我是 Play 框架的新手。我正在尝试将 MySQL 数据库配置为与 Play Ebeans 一起使用的数据源。
能否请您解释一下使用 Play 2.0 框架配置 MySQL 所需的步骤(例如,下载驱动程序、添加依赖项等)。
最佳答案
看this page来自 Play 的文档。它说:
Other than for the h2 in-memory database, useful mostly in development mode, Play 2.0 does not provide any database drivers. Consequently, to deploy in production you will have to add your database driver as an application dependency.
For example, if you use MySQL5, you need to add a dependency for the connector:
val appDependencies = Seq(
// Add your project dependencies here,
...
"mysql" % "mysql-connector-java" % "5.1.18"
...
)
SBT 将为您下载驱动程序。您还应该查看 section on managing dependencies .
要连接 MySQL,您还需要更改 application.conf
中的一些设置:
db.default.driver=com.mysql.jdbc.Driver
db.default.url="mysql://root:secret@localhost/myDatabase"
关于java - 在 Play framework 2.0 中使用 MySQL 数据库所需的步骤,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10007029/