1
PostgreSQLドライバを使用してIntellij IDEAのSlickでプロジェクトを作成しようとしています。しかし、私はそれだけを見つけることができましたthis tutorial 私はそれに続いて、エラーが発生しました: スレッド "main"の例外java.lang.ExceptionInInitializerError Main.main(Main.scala)の で例外:com.typesafe行方不明config.ConfigException $:Slick With PostgreSQL Scala SBT Intellij IDEA
scalaxdb = {
dataSourceClass = "slick.jdbc.DatabaseUrlDataSource"
properties = {
driver = "org.postgresql.Driver"
url = "jdbc:postgresql://localhost/dbname?user=user&password=password"
}
}
:これらは、application.confファイルである
import scala.slick.driver.PostgresDriver.simple._
object Main {
case class Song(
id: Int,
name: String,
singer: String)
class SongsTable(tag: Tag) extends Table[Song](tag, "songs") {
def id = column[Int]("id")
def name = column[String]("name")
def singer = column[String]("singer")
def * = (id, name, singer) <> (Song.tupled, Song.unapply)
}
lazy val songsTable = TableQuery[SongsTable]
val db = Database.forConfig("scalaxdb")
def main(args: Array[String]): Unit = {
val connectionUrl = "jdbc:postgresql://localhost/songs?user=postgres&password=postgresp"
Database.forURL(connectionUrl, driver = "org.postgresql.Driver") withSession {
implicit session =>
val songs = TableQuery[SongsTable]
songs.list foreach { row =>
println("song with id " + row.id + " has name " + row.name + " and a singer is " + row.singer)
}
}
}
}
:キー 'URL' ここ
が見つかりません構成設定は、メインクラスのための私のコードです
そして、これはbuild.sbtです:
libraryDependencies ++= Seq(
"org.postgresql" % "postgresql" % "9.3-1100-jdbc4",
"com.typesafe.slick" %% "slick" % "2.1.0",
"org.slf4j" % "slf4j-nop" % "1.6.4"
)
私は私が間違っているのかを把握することはできません。私はこれを修正するためのアドバイスに非常に感謝しています。