我是Play框架的新手。我正在尝试将MySQL数据库配置为与Play Ebeans一起使用的数据源。
I'm new to Play framework. I'm trying to configure MySQL database as a datasource to be used with Play Ebeans.
请问您能解释一下使用Play 2.0框架配置MySQL所需的步骤(例如,下载驱动程序,添加依赖项等)。
Could you some one please explain the steps that are needed to configure MySQL with Play 2.0 framework (like, downloading drivers, adding dependency etc).
推荐答案查看此页面来自Play的文档。它说:
Look at this page from Play's documentation. It says:
除了h2内存数据库(主要用于开发模式)之外,Play 2.0不提供任何数据库驱动程序。因此,要在生产中进行部署,您必须将数据库驱动程序添加为应用程序依赖项。
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.
例如,如果使用MySQL5,则需要为其添加依赖项。连接器:
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将为您下载驱动程序。您还应该查看管理依赖关系部分。
SBT will download the driver for you. You should also check out the section on managing dependencies.
要连接到MySQL,您还需要更改 application.conf中的一些设置:
To connect to MySQL, you will also need to change some settings in your application.conf:
db.default.driver=com.mysql.jdbc.Driver db.default.url="mysql://root:secret@localhost/myDatabase"更多推荐
在Play framework 2.0中使用MySQL数据库所需的步骤
发布评论