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.host | define the mongodb server host to be connected. Note this configuration is deprecated. Please use morphia.db.seeds instead | localhost |
morphia.db.port | define the mongodb server port to be connected. Note this is deprecated. Please use morphia.db.seeds instead | 27017 |
morphia.db.name | define the database name that is accessed by the application | test |
morphia.db.seeds | define 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.url | define connection using url style: mongodb://username:password@host:port/db . Note this item takes precedence of morphia.db.seeds configuration | None |
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.username | define the username to be used to access MongoDB. See MongoDB security and authentication | blank |
morphia.db.password | define the password to be used to access MongoDB. See MongoDB security and authentication | blank |
When either one of the above configuration is missing, PlayMorphia will try to access MongoDB without authentication.
Miscellaneous configurations
ID | Description | default value |
---|---|---|
morphia.logger | Enable/disable Morphia log. When this configuration set to true, Morphia log is enabled. Remove this confiuration item to disable Morphia log | false |
morphia.collection.upload | Set the GridFS collection name | uploads |
morphia.id.type | Define the default ID field type. Could be any one of String , "Long " and "ObjectId " | ObjectId |
morphia.id.stringIdGenerator | Only effective when morphia.id.type is set to String . Define the String ID generator. Could be anyone of ObjectId or UUID | ObjectId |
morphia.postPluginEvent | When 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 bit | false |
morphia.autoRegisterEventHandler | When set to true, PlayMorphia will automatically register lifecycle event handler using annotations. See here | true |
morphia.defaultWriteConcern | Set default writeconcern. Could one of "FSYNC_SAFE ", "NONE ", "NORMAL ", "REPLICAS_SAFE ", "SAFE ". See here for details | SAFE |