【问题标题】:Why am i unable to connect to MYSQL database with PlayFrameworks为什么我无法使用 PlayFrameworks 连接到 MYSQL 数据库
【发布时间】:2018-12-01 13:05:59
【问题描述】:

我正在尝试通过 Play 框架连接到 Mysql 数据库。我已经阅读了一堆教程,我认为我正在认真做这件事。我怎么没有得到 ​​p>

“数据库‘默认’需要进化 - 警告。”相反,我得到了 playframework 索引页面。(这意味着它正在运行。我认为这意味着数据库未连接)。

我的 application.conf 有以下内容

bean.default = ["models.*"]

play.evolution{
db.default.enabled=true
}

db{
default.driver = com.mysql.jdbc.Driver
default.url="jdbc:mysql://localhost:3306/hope"
default.username = root
default.password = ""

default.logSql = true
}

以下是我的 build.sbt

 name := """myfirstapp"""
 organization := "any"

 version := "1.0-SNAPSHOT"

 lazy val root = (project in file(".")).enablePlugins(PlayJava,PlayEbean)

 scalaVersion := "2.12.6"

 libraryDependencies += jdbc
 libraryDependencies += guice

 libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.41"

我不确定我在做什么。 我收到以下日志。

(Server started, use Enter to stop and go back to the console...)

 [info] p.a.d.DefaultDBApi - Database [default] initialized at 
 jdbc:mysql://localhost/hope
 [info] application - Creating Pool for datasource 'default'
 [warn] o.h.v.m.ParameterMessageInterpolator - HV000184: 
 ParameterMessageInterpolator has been chosen, EL interpolation will not be 
 supported
 [info] p.a.h.EnabledFilters - Enabled Filters (see 
 <https://www.playframework.com/documentation/latest/Filters>):

play.filters.csrf.CSRFFilter
play.filters.headers.SecurityHeadersFilter
play.filters.hosts.AllowedHostsFilter

根据它正在初始化连接的数据库。但没有连接,也没有给我任何错误。谁能告诉我哪里出错了

【问题讨论】:

  • 我猜您的实体的路径无法识别。对于 Java 的 play 2.6,我使用 ebean.default = "..." 而不是 bean.default = "..." 也许这会有所帮助。
  • @gsprs 这是否意味着我无法使用这个版本的游戏来这样做
  • 我不确定,但您可以尝试使用 ebean 看看是否适合您

标签: mysql angularjs database playframework


【解决方案1】:

使用查询参数useSSL=false

例如“jdbc:mysql://localhost/test?useSSL=false”

使用更高版本的mysql连接器。

libraryDependencies += "mysql" % "mysql-connector-java" % "8.0.12"

【讨论】:

    猜你喜欢
    • 2018-03-01
    • 2018-10-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多