Module io.ebean.api

Class DatabaseConfig

java.lang.Object
io.ebean.config.DatabaseConfig
All Implemented Interfaces:
DatabaseBuilder, DatabaseBuilder.Settings

public class DatabaseConfig extends Object implements DatabaseBuilder.Settings
The configuration used for creating a Database.

Used to programmatically construct an Database and optionally register it with the DB singleton.

If you just use DB thout this programmatic configuration Ebean will read the application.properties file and take the configuration from there. This usually includes searching the class path and automatically registering any entity classes and listeners etc.



 DatabaseConfig config = new DatabaseConfig();

 // read the ebean.properties and load
 // those settings into this DatabaseConfig object
 config.loadFromProperties();

 // explicitly register the entity beans to avoid classpath scanning
 config.addClass(Customer.class);
 config.addClass(User.class);

 Database db = DatabaseFactory.create(config);

 

Note that DatabaseConfigProvider provides a standard Java ServiceLoader mechanism that can be used to apply configuration to the DatabaseConfig.

Author:
emcgreal, rbygrave
See Also: