Play2.0でMySQLにつなぐ
jdbcのドライバがないと言われたので、mysql-connector-j.rbを書いてhomebrewでインストールした。
/usr/local/Library/Formula/mysql-connector-j.rb
#http://goo.gl/4pkdPからコピペ
require 'formula'
class MysqlConnectorJ < Formula
homepage 'http://dev.mysql.com/downloads/connector/j/5.1.html'
url 'http://downloads.mysql.com/archives/mysql-connector-java-5.1/mysql-connector-java-5.1.13.zip'
md5 '2e1bbd848bc99fe1c8ae9ce980adc2c9'
def install
prefix.install ['README', 'COPYING', 'mysql-connector-java-5.1.13-bin.jar']
end
def caveats
<<-EOS.undent
To enable Java to find Connector/J, add the following to the
front of your CLASSPATH:
#{prefix}
If this is an upgrade and you have previously added the symlinks
to your CLASSPATH, you will need to modify it to the path specified
above so it points to the new version.
EOS
end
end
インストールしたあと下記のようにファイルを設定した(たぶん再コンパイル必要)
testproject/project/Build.scala
import sbt._
import Keys._
import PlayProject._
object ApplicationBuild extends Build {
val appName = "testproject"
val appVersion = "1.0-SNAPSHOT"
val appDependencies = Seq(
// Add your project dependencies here,
"mysql" % "mysql-connector-java" % "5.1.13"
)
val main = PlayProject(appName, appVersion, appDependencies, mainLang = SCALA).settings(
// Add your own project settings here
)
}
testproject/conf/application.conf
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://host/databasename?characterEncoding=UTF8"
db.default.user=user
db.default.password=password
Author And Source
この問題について(Play2.0でMySQLにつなぐ), 我々は、より多くの情報をここで見つけました https://qiita.com/puriketu99/items/dfa8758bdf4172b175c7著者帰属:元の著者の情報は、元のURLに含まれています。著作権は原作者に属する。
Content is automatically searched and collected through network algorithms . If there is a violation . Please contact us . We will adjust (correct author information ,or delete content ) as soon as possible .