Java Code Examples for io.ebean.config.ServerConfig#setDefaultServer()
The following examples show how to use
io.ebean.config.ServerConfig#setDefaultServer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SampleConfig.java From spring-data-ebean with Apache License 2.0 | 6 votes |
@SuppressWarnings("SpringJavaAutowiringInspection") @Bean @Primary public ServerConfig defaultEbeanServerConfig() { ServerConfig config = new ServerConfig(); config.setDataSource(dataSource()); config.setExternalTransactionManager(new SpringJdbcTransactionManager()); config.loadFromProperties(); config.setDefaultServer(true); config.setRegister(true); config.setAutoCommitMode(false); config.setExpressionNativeIlike(true); config.setCurrentUserProvider(new CurrentUserProvider() { @Override public Object currentUser() { return "test"; // just for test, can rewrite to get the currentUser from threadLocal } }); return config; }
Example 2
Source File: App2.java From tutorials with MIT License | 5 votes |
public static void main(String[] args) { ServerConfig cfg = new ServerConfig(); cfg.setDefaultServer(true); Properties properties = new Properties(); properties.put("ebean.db.ddl.generate", "true"); properties.put("ebean.db.ddl.run", "true"); properties.put("datasource.db.username", "sa"); properties.put("datasource.db.password", ""); properties.put("datasource.db.databaseUrl", "jdbc:h2:mem:app2"); properties.put("datasource.db.databaseDriver", "org.h2.Driver"); cfg.loadFromProperties(properties); EbeanServer server = EbeanServerFactory.create(cfg); }
Example 3
Source File: EbeanConfig.java From canal with Apache License 2.0 | 5 votes |
@Bean("ebeanServer") public EbeanServer ebeanServer(DataSource dataSource) { ServerConfig serverConfig = new ServerConfig(); serverConfig.setDefaultServer(true); serverConfig.setNamingConvention(new UnderscoreNamingConvention()); List<String> packages = new ArrayList<>(); packages.add("com.alibaba.otter.canal.admin.model"); serverConfig.setPackages(packages); serverConfig.setName("ebeanServer"); serverConfig.setDataSource(dataSource); serverConfig.setDatabaseSequenceBatchSize(1); serverConfig.setDdlGenerate(false); serverConfig.setDdlRun(false); return EbeanServerFactory.create(serverConfig); }
Example 4
Source File: DefaultEbeanConfig.java From play-ebean with Apache License 2.0 | 3 votes |
/** * Reads the configuration and creates config for Ebean servers. * * @return a config for Ebean servers. */ public EbeanConfig parse() { EbeanParsedConfig ebeanConfig = EbeanParsedConfig.parseFromConfig(config); Map<String, ServerConfig> serverConfigs = new HashMap<>(); for (Map.Entry<String, List<String>> entry: ebeanConfig.getDatasourceModels().entrySet()) { String key = entry.getKey(); ServerConfig serverConfig = new ServerConfig(); serverConfig.setName(key); serverConfig.loadFromProperties(); setServerConfigDataSource(key, serverConfig); if (!ebeanConfig.getDefaultDatasource().equals(key)) { serverConfig.setDefaultServer(false); } Set<String> classes = getModelClasses(entry); addModelClassesToServerConfig(key, serverConfig, classes); serverConfigs.put(key, serverConfig); } return new DefaultEbeanConfig(ebeanConfig.getDefaultDatasource(), serverConfigs); }