我从 Java 和 Play Framework 开始,我尝试配置数据库 mysql。但我有以下错误:
ProvisionException: Unable to provision, see the following errors: 1) No implementation for play.db.Database annotated with @play.db.NamedDatabase(value=baseplay) was bound.
我有我的课:
// inject "orders" database instead of "default"
@javax.inject.Singleton
public class JavaApplicationDataBase implements IWidgetRepository {
private Database db;
private DatabaseExecutionContext executionContext;
@Inject
public JavaApplicationDataBase(@NamedDatabase("baseplay") Database db, DatabaseExecutionContext executionContext) {
this.db = db;
this.executionContext = executionContext;
}
文件配置“application.conf”:
# Default database configuration
db.default.driver=com.mysql.jdbc.Driver
db.default.url="jdbc:mysql://localhost/baseplay"
db.default.username=root
db.default.password="root"
和配置文件'build.sbt':
name := """play-java-forms-example"""
version := "2.6.x"
lazy val root = (project in file(".")).enablePlugins(PlayJava)
scalaVersion := "2.12.4"
crossScalaVersions := Seq("2.11.12", "2.12.4")
testOptions in Test := Seq(Tests.Argument(TestFrameworks.JUnit, "-a", "-v"))
libraryDependencies += guice
EclipseKeys.preTasks := Seq(compile in Compile, compile in Test)
libraryDependencies += javaJdbc
libraryDependencies ++= Seq(
cache,
ws,
specs2 % Test,
"mysql" % "mysql-connector-java" % "5.1.41"
)
谢谢。