Why does Play 2.3 application give me “Driver not found: [com.mysql.jdbc.Driver]” at startup with MySQL setup in application.conf?

StackOverflow https://stackoverflow.com//questions/25060764

Question

I have created a test Play 2.3 application with the help of activator and the play-scala template:

activator new test play-scala

This is build.sbt:

name := """test"""

version := "1.0-SNAPSHOT"

lazy val root = (project in file(".")).enablePlugins(PlayScala)

scalaVersion := "2.11.1"

libraryDependencies ++= Seq(
 jdbc,
 anorm,
 cache,
 ws
)

In application.conf I've set up MySQL to be the database for the application:

db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost:3306/*******?characterEncoding=UTF-8"
db.default.user=root
db.default.password="********"

When I type activator run in console it starts the server on localhost and the port 9999 just fine. However, when I open the application in my browser I get the following error:

Configuration error
Driver not found: [com.mysql.jdbc.Driver]

What am I doing wrong?

Was it helpful?

Solution

You need to add the mysql driver to your build.sbt:

libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.27"
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top