Community contributed extensions

PlayMorphia configuration

This page list all available configuration items along with it’s definition and default value. To use PlayMorphia configuration, you just need to add them into your conf/application.conf file. If a configuration item is missing from the conf/application.conf then it’s default value will be used.

MongoDB Connection

ID Description default value
morphia.db.hostdefine the mongodb server host to be connected. Note this configuration is deprecated. Please use morphia.db.seeds insteadlocalhost
morphia.db.portdefine the mongodb server port to be connected. Note this is deprecated. Please use morphia.db.seeds instead27017
morphia.db.namedefine the database name that is accessed by the applicationtest
morphia.db.seedsdefine mongodb server to be connected. Note, this item takes precedence over morphia.db.host and morphia.db.port. E.g, server1:port1,server2:port2...None
morphia.db.urldefine connection using url style: mongodb://username:password@host:port/db. Note this item takes precedence of morphia.db.seeds configurationNone

MongoDB Driver Options

You can also set MongoDB driver options in conf/application.conf like this:

## Mongo driver configuration
morphia.driver.threadsAllowedToBlockForConnectionMultiplier=10
morphia.driver.connectionsPerHost=20
morphia.driver.slaveOk=true

Secure MongoDB access

ID Description default value
morphia.db.usernamedefine the username to be used to access MongoDB. See MongoDB security and authenticationblank
morphia.db.passworddefine the password to be used to access MongoDB. See MongoDB security and authenticationblank

When either one of the above configuration is missing, PlayMorphia will try to access MongoDB without authentication.

Miscellaneous configurations

ID Description default value
morphia.loggerEnable/disable Morphia log. When this configuration set to true, Morphia log is enabled. Remove this confiuration item to disable Morphia logfalse
morphia.collection.uploadSet the GridFS collection nameuploads
morphia.id.typeDefine the default ID field type. Could be any one of String, "Long" and "ObjectId"ObjectId
morphia.id.stringIdGeneratorOnly effective when morphia.id.type is set to String. Define the String ID generator. Could be anyone of ObjectId or UUIDObjectId
morphia.postPluginEventWhen set to true, PlayMorphia will post entity lifecycle events to Play plugin’s event framework. Note turning on this configuration might impact performance a little bitfalse
morphia.autoRegisterEventHandlerWhen set to true, PlayMorphia will automatically register lifecycle event handler using annotations. See heretrue
morphia.defaultWriteConcernSet default writeconcern. Could one of "FSYNC_SAFE", "NONE", "NORMAL", "REPLICAS_SAFE", "SAFE". See here for detailsSAFE

See also

  1. Getting start
  2. Morphia documentation home