Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 捕捉游戏中的配置错误!框架2.0.4_Java_Database_Configuration_Playframework 2.0_Global - Fatal编程技术网

Java 捕捉游戏中的配置错误!框架2.0.4

Java 捕捉游戏中的配置错误!框架2.0.4,java,database,configuration,playframework-2.0,global,Java,Database,Configuration,Playframework 2.0,Global,我的剧本!2.0.4 web应用目前连接多个RDS MySQL数据库,配置文件如下: # Africa db.afr.url="jdbc:mysql://<africa-server>:3306/users" db.afr.driver=com.mysql.jdbc.Driver db.afr.user=user1 db.afr.password=**** db.afr.logStatements=true # Europe

我的剧本!2.0.4 web应用目前连接多个RDS MySQL数据库,配置文件如下:

    # Africa
    db.afr.url="jdbc:mysql://<africa-server>:3306/users"
    db.afr.driver=com.mysql.jdbc.Driver
    db.afr.user=user1
    db.afr.password=****
    db.afr.logStatements=true

    # Europe
    db.eur.url="jdbc:mysql://<europe-server>:3306/users"
    db.eur.driver=com.mysql.jdbc.Driver
    db.eur.user=user1
    db.eur.password=****
    db.eur.logStatements=true
非洲 db.afr.url=“jdbc:mysql://:3306/users” db.afr.driver=com.mysql.jdbc.driver db.afr.user=user1 db.afr.password=**** db.afr.logStatements=true #欧洲 db.eur.url=“jdbc:mysql://:3306/users” db.eur.driver=com.mysql.jdbc.driver db.eur.user=user1 db.eur.password=**** db.eur.logStatements=true 当所有的数据库都在运行时,这种方法工作得很好。但是,如果其中一个数据库关闭(无论出于何种原因),整个应用程序将失败,并引发配置错误(无法连接到数据库[afr])

如何在启动时捕获配置错误以捕获并忽略/记录这些消息,而不是完全终止服务器?我曾研究过使用Global.java的onError()重写,但我在这方面运气不佳

谢谢,
大卫

以下是我最后做的事情。这不是一个很好的解决方案,但可能是一个可行的解决方案

将play.api.db.BoneCPPlugin的内容复制到您自己的文件SafeDBPlugin.scala中,类名为SafeDBPlugin。它需要放在play.api.db包中(尽管您可以像往常一样将文件放在代码库中的任何位置)。重要的部分是更改方法onStartup()中报告配置错误的行,并将其更改为logger.warn()

通过在application.conf中添加以下行来禁用内置dbplugin(BoneCPPlugin):

dbplugin=disabled
通过将以下行添加到play.plugins来添加新插件:

600:play.api.db.SafeDBPlugin