在Play framework 2.0中使用MySQL数据库所需的步骤

编程入门 行业动态 更新时间:2024-10-21 11:44:15
本文介绍了在Play framework 2.0中使用MySQL数据库所需的步骤的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我是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数据库所需的步骤

本文发布于:2023-07-14 21:56:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1107264.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:所需   步骤   数据库   framework   Play

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!