@Bean(destroyMethod = "close") @ConditionalOnExpression("#{!environment.acceptsProfiles('" + Constants.SPRING_PROFILE_CLOUD + "') && !environment.acceptsProfiles('" + Constants.SPRING_PROFILE_HEROKU + "')}") @ConfigurationProperties(prefix = "spring.datasource.hikari") public DataSource dataSource(DataSourceProperties dataSourceProperties) { log.debug("Configuring Datasource"); if (dataSourceProperties.getUrl() == null) { log.error("Your database connection pool configuration is incorrect! The application" + " cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariDataSource hikariDataSource = (HikariDataSource) DataSourceBuilder .create(dataSourceProperties.getClassLoader()) .type(HikariDataSource.class) .driverClassName(dataSourceProperties.getDriverClassName()) .url(dataSourceProperties.getUrl()) .username(dataSourceProperties.getUsername()) .password(dataSourceProperties.getPassword()) .build(); if (metricRegistry != null) { hikariDataSource.setMetricRegistry(metricRegistry); } return hikariDataSource; }
@Bean(destroyMethod = "close") @ConditionalOnExpression("#{!environment.acceptsProfiles('cloud') && !environment.acceptsProfiles('heroku')}") public DataSource dataSource() { log.debug("Configuring Datasource"); if (dataSourcePropertyResolver.getProperty("url") == null && dataSourcePropertyResolver.getProperty("databaseName") == null) { log.error("Your database connection pool configuration is incorrect! The application" + " cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariConfig config = new HikariConfig(); config.setDataSourceClassName(dataSourcePropertyResolver.getProperty("dataSourceClassName")); if (StringUtils.isEmpty(dataSourcePropertyResolver.getProperty("url"))) { config.addDataSourceProperty("databaseName", dataSourcePropertyResolver.getProperty("databaseName")); config.addDataSourceProperty("serverName", dataSourcePropertyResolver.getProperty("serverName")); } else { config.addDataSourceProperty("url", dataSourcePropertyResolver.getProperty("url")); } config.addDataSourceProperty("user", dataSourcePropertyResolver.getProperty("username")); config.addDataSourceProperty("password", dataSourcePropertyResolver.getProperty("password")); if (metricRegistry != null) { config.setMetricRegistry(metricRegistry); } return new HikariDataSource(config); }
@Bean(destroyMethod = "close") @ConditionalOnExpression("#{!environment.acceptsProfiles('cloud') && !environment.acceptsProfiles('heroku')}") public DataSource dataSource(DataSourceProperties dataSourceProperties, ApplicationProperties applicationProperties) { log.debug("Configuring Datasource"); if (dataSourceProperties.getUrl() == null) { log.error("Your database connection pool configuration is incorrect! The application cannot start. " + "Please check your Spring profile, current profiles are: {}", Arrays.toString(environment.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariConfig config = new HikariConfig(); config.setDataSourceClassName(dataSourceProperties.getDriverClassName()); config.addDataSourceProperty("url", dataSourceProperties.getUrl()); config.addDataSourceProperty("user", dataSourceProperties.getUsername() != null ? dataSourceProperties.getUsername() : ""); config.addDataSourceProperty("password", dataSourceProperties.getPassword() != null ? dataSourceProperties.getPassword() : ""); if (metricRegistry != null) { config.setMetricRegistry(metricRegistry); } return new HikariDataSource(config); }
@Bean(destroyMethod = "close") @ConditionalOnExpression("#{!environment.acceptsProfiles('cloud') && !environment.acceptsProfiles('heroku')}") public DataSource dataSource(DataSourceProperties dataSourceProperties, JHipsterProperties jHipsterProperties) { log.debug("Configuring Datasource"); if (dataSourceProperties.getUrl() == null) { log.error("Your database connection pool configuration is incorrect! The application" + " cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariConfig config = new HikariConfig(); config.setDataSourceClassName(dataSourceProperties.getDriverClassName()); config.addDataSourceProperty("url", dataSourceProperties.getUrl()); if (dataSourceProperties.getUsername() != null) { config.addDataSourceProperty("user", dataSourceProperties.getUsername()); } else { config.addDataSourceProperty("user", ""); // HikariCP doesn't allow null user } if (dataSourceProperties.getPassword() != null) { config.addDataSourceProperty("password", dataSourceProperties.getPassword()); } else { config.addDataSourceProperty("password", ""); // HikariCP doesn't allow null password } if (metricRegistry != null) { config.setMetricRegistry(metricRegistry); } return new HikariDataSource(config); }
@Bean @Order(2) @ConditionalOnExpression("${xm-config.enabled} && ${tenant.reject-suspended:true}") TenantVerifyInterceptor tenantVerifyInterceptor(TenantListRepository tenantListRepository, TenantContextHolder tenantContextHolder) { return new TenantVerifyInterceptor(tenantListRepository, tenantContextHolder); }
@Bean(destroyMethod = "close") @ConditionalOnExpression("#{!environment.acceptsProfiles('cloud') && !environment.acceptsProfiles('heroku')}") public DataSource dataSource(DataSourceProperties dataSourceProperties, LeagueProperties leagueProperties) { log.debug("Configuring Datasource"); if (dataSourceProperties.getUrl() == null) { log.error("Your database connection pool configuration is incorrect! The application" + " cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariConfig config = new HikariConfig(); config.setDataSourceClassName(dataSourceProperties.getDriverClassName()); config.addDataSourceProperty("url", dataSourceProperties.getUrl()); if (dataSourceProperties.getUsername() != null) { config.addDataSourceProperty("user", dataSourceProperties.getUsername()); } else { config.addDataSourceProperty("user", ""); // HikariCP doesn't allow null user } if (dataSourceProperties.getPassword() != null) { config.addDataSourceProperty("password", dataSourceProperties.getPassword()); } else { config.addDataSourceProperty("password", ""); // HikariCP doesn't allow null password } //MySQL optimizations, see https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration if ("com.mysql.jdbc.jdbc2.optional.MysqlDataSource".equals(dataSourceProperties.getDriverClassName())) { config.addDataSourceProperty("cachePrepStmts", leagueProperties.getDatasource().isCachePrepStmts()); config.addDataSourceProperty("prepStmtCacheSize", leagueProperties.getDatasource().getPrepStmtCacheSize()); config.addDataSourceProperty("prepStmtCacheSqlLimit", leagueProperties.getDatasource().getPrepStmtCacheSqlLimit()); } if (metricRegistry != null) { config.setMetricRegistry(metricRegistry); } if (healthCheckRegistry != null) { config.setHealthCheckRegistry(healthCheckRegistry); } return new HikariDataSource(config); }
@Bean(destroyMethod = "shutdown") @ConditionalOnExpression("#{!environment.acceptsProfiles('cloud') && !environment.acceptsProfiles('heroku')}") public DataSource dataSource() { log.debug("Configuring Datasource"); if (dataSourcePropertyResolver.getProperty("url") == null && dataSourcePropertyResolver.getProperty("databaseName") == null) { log.error( "Your database connection pool configuration is incorrect! The application" + " cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariConfig config = new HikariConfig(); config.setDataSourceClassName(dataSourcePropertyResolver.getProperty("dataSourceClassName")); if (StringUtils.isEmpty(dataSourcePropertyResolver.getProperty("url"))) { config.addDataSourceProperty("databaseName", dataSourcePropertyResolver.getProperty("databaseName")); config.addDataSourceProperty("serverName", dataSourcePropertyResolver.getProperty("serverName")); } else { config.addDataSourceProperty("url", dataSourcePropertyResolver.getProperty("url")); } config.addDataSourceProperty("user", dataSourcePropertyResolver.getProperty("username")); config.addDataSourceProperty("password", dataSourcePropertyResolver.getProperty("password")); if (metricRegistry != null) { config.setMetricRegistry(metricRegistry); } return new HikariDataSource(config); }
@Bean @ConditionalOnExpression("#{environment.getProperty('grpc.inProcessServerName','')!=''}") public GRpcServerRunner grpcInprocessServerRunner(GRpcServerBuilderConfigurer configurer){ return new GRpcServerRunner(configurer, InProcessServerBuilder.forName(grpcServerProperties.getInProcessServerName())); }
@Bean @ConditionalOnExpression("${fiat.writeMode.enabled:true}") String addUnrestrictedUser(PermissionsRepository permissionsRepository) { if (!permissionsRepository.get(UNRESTRICTED_USERNAME).isPresent()) { permissionsRepository.put(new UserPermission().setId(UNRESTRICTED_USERNAME)); } return UNRESTRICTED_USERNAME; }
@Bean(destroyMethod = "close") @ConditionalOnExpression("#{!environment.acceptsProfiles('" + Constants.SPRING_PROFILE_CLOUD + "') && !environment.acceptsProfiles('" + Constants.SPRING_PROFILE_HEROKU + "')}") @ConfigurationProperties(prefix = "spring.datasource.hikari") public DataSource dataSource(DataSourceProperties dataSourceProperties<% if (hibernateCache == 'hazelcast') { %>, CacheManager cacheManager<% } %>) { log.debug("Configuring Datasource"); if (dataSourceProperties.getUrl() == null) { log.error("Your database connection pool configuration is incorrect! The application" + " cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariDataSource hikariDataSource = (HikariDataSource) DataSourceBuilder .create(dataSourceProperties.getClassLoader()) .type(HikariDataSource.class) .driverClassName(dataSourceProperties.getDriverClassName()) .url(dataSourceProperties.getUrl()) .username(dataSourceProperties.getUsername()) .password(dataSourceProperties.getPassword()) .build(); if (metricRegistry != null) { hikariDataSource.setMetricRegistry(metricRegistry); } return hikariDataSource; } <%_ if (devDatabaseType == 'h2Disk' || devDatabaseType == 'h2Memory') { _%>
@Bean(destroyMethod = "close") @ConditionalOnExpression("#{!environment.acceptsProfiles('cloud') && !environment.acceptsProfiles('heroku')}") public DataSource dataSource(DataSourceProperties dataSourceProperties, JHipsterProperties jHipsterProperties) { log.debug("Configuring Datasource"); if (dataSourceProperties.getUrl() == null) { log.error("Your database connection pool configuration is incorrect! The application" + " cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariConfig config = new HikariConfig(); config.setDataSourceClassName(dataSourceProperties.getDriverClassName()); config.addDataSourceProperty("url", dataSourceProperties.getUrl()); if (dataSourceProperties.getUsername() != null) { config.addDataSourceProperty("user", dataSourceProperties.getUsername()); } else { config.addDataSourceProperty("user", ""); // HikariCP doesn't allow null user } if (dataSourceProperties.getPassword() != null) { config.addDataSourceProperty("password", dataSourceProperties.getPassword()); } else { config.addDataSourceProperty("password", ""); // HikariCP doesn't allow null password } //MySQL optimizations, see https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration if ("com.mysql.jdbc.jdbc2.optional.MysqlDataSource".equals(dataSourceProperties.getDriverClassName())) { config.addDataSourceProperty("cachePrepStmts", jHipsterProperties.getDatasource().isCachePrepStmts()); config.addDataSourceProperty("prepStmtCacheSize", jHipsterProperties.getDatasource().getPrepStmtCacheSize()); config.addDataSourceProperty("prepStmtCacheSqlLimit", jHipsterProperties.getDatasource().getPrepStmtCacheSqlLimit()); } if (metricRegistry != null) { config.setMetricRegistry(metricRegistry); } return new HikariDataSource(config); }
@Bean @ConditionalOnMissingBean @ConditionalOnExpression("#{'${" + FeaturesProperties.FEATURES_PREFIX + "." + FeaturesProperties.STREAMS_ENABLED + ":true}'.equalsIgnoreCase('true') || " + "'${" + FeaturesProperties.FEATURES_PREFIX + "." + FeaturesProperties.TASKS_ENABLED + ":true}'.equalsIgnoreCase('true') }") public DeploymentIdRepository deploymentIdRepository(DataSource dataSource) { return new RdbmsDeploymentIdRepository(dataSource); }
@Bean(destroyMethod = "shutdown") @ConditionalOnExpression("#{!environment.acceptsProfiles('cloud') && !environment.acceptsProfiles('heroku')}") public DataSource dataSource() { log.debug("Configuring Datasource"); if (dataSourcePropertyResolver.getProperty("url") == null && dataSourcePropertyResolver.getProperty("databaseName") == null) { log.error("Your database connection pool configuration is incorrect! The application" + " cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariConfig config = new HikariConfig(); config.setDataSourceClassName(dataSourcePropertyResolver.getProperty("dataSourceClassName")); if(StringUtils.isEmpty(dataSourcePropertyResolver.getProperty("url"))) { config.addDataSourceProperty("databaseName", dataSourcePropertyResolver.getProperty("databaseName")); config.addDataSourceProperty("serverName", dataSourcePropertyResolver.getProperty("serverName")); } else { config.addDataSourceProperty("url", dataSourcePropertyResolver.getProperty("url")); } config.addDataSourceProperty("user", dataSourcePropertyResolver.getProperty("username")); config.addDataSourceProperty("password", dataSourcePropertyResolver.getProperty("password")); //MySQL optimizations, see https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration if ("com.mysql.jdbc.jdbc2.optional.MysqlDataSource".equals(dataSourcePropertyResolver.getProperty("dataSourceClassName"))) { config.addDataSourceProperty("cachePrepStmts", dataSourcePropertyResolver.getProperty("cachePrepStmts", "true")); config.addDataSourceProperty("prepStmtCacheSize", dataSourcePropertyResolver.getProperty("prepStmtCacheSize", "250")); config.addDataSourceProperty("prepStmtCacheSqlLimit", dataSourcePropertyResolver.getProperty("prepStmtCacheSqlLimit", "2048")); } if (metricRegistry != null) { config.setMetricRegistry(metricRegistry); } return new HikariDataSource(config); }
@Bean(destroyMethod = "shutdown") @ConditionalOnExpression("#{!environment.acceptsProfiles('cloud') && !environment.acceptsProfiles('heroku')}") public DataSource dataSource() { log.debug("Configuring Datasource"); if (dataSourcePropertyResolver.getProperty("url") == null && dataSourcePropertyResolver.getProperty("databaseName") == null) { log.error("Your database connection pool configuration is incorrect! The application" + " cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariConfig config = new HikariConfig(); config.setDataSourceClassName(dataSourcePropertyResolver.getProperty("dataSourceClassName")); if(StringUtils.isEmpty(dataSourcePropertyResolver.getProperty("url"))) { config.addDataSourceProperty("databaseName", dataSourcePropertyResolver.getProperty("databaseName")); config.addDataSourceProperty("serverName", dataSourcePropertyResolver.getProperty("serverName")); } else { config.addDataSourceProperty("url", dataSourcePropertyResolver.getProperty("url")); } config.addDataSourceProperty("user", dataSourcePropertyResolver.getProperty("username")); config.addDataSourceProperty("password", dataSourcePropertyResolver.getProperty("password")); if (metricRegistry != null) { config.setMetricRegistry(metricRegistry); } return new HikariDataSource(config); }
@Bean(destroyMethod = "close") @ConditionalOnExpression("#{!environment.acceptsProfiles('cloud') && !environment.acceptsProfiles('heroku')}") public DataSource dataSource() { log.debug("Configuring Datasource"); if (dataSourcePropertyResolver.getProperty("url") == null && dataSourcePropertyResolver.getProperty("databaseName") == null) { log.error("Your database connection pool configuration is incorrect! The application" + " cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariConfig config = new HikariConfig(); config.setDataSourceClassName(dataSourcePropertyResolver.getProperty("dataSourceClassName")); if(StringUtils.isEmpty(dataSourcePropertyResolver.getProperty("url"))) { config.addDataSourceProperty("databaseName", dataSourcePropertyResolver.getProperty("databaseName")); config.addDataSourceProperty("serverName", dataSourcePropertyResolver.getProperty("serverName")); } else { config.addDataSourceProperty("url", dataSourcePropertyResolver.getProperty("url")); } config.addDataSourceProperty("user", dataSourcePropertyResolver.getProperty("username")); config.addDataSourceProperty("password", dataSourcePropertyResolver.getProperty("password")); if (metricRegistry != null) { config.setMetricRegistry(metricRegistry); } return new HikariDataSource(config); }
/** * mybatis-plus 性能分析拦截器<br> * 文档:http://mp.baomidou.com<br> */ @Bean @ConditionalOnExpression( "${aidijing.mybatis-plus.performance-interceptor.enabled:false}" ) public PerformanceInterceptor performanceInterceptor () { return new PerformanceInterceptor(); }
@Bean(destroyMethod = "close") @ConditionalOnExpression("#{!environment.acceptsProfiles('cloud') && !environment.acceptsProfiles('heroku')}") public DataSource dataSource(DataSourceProperties dataSourceProperties, JHipsterProperties jHipsterProperties) { log.debug("Configuring Datasource"); if(env.acceptsProfiles("aws")){ String url = String.format("jdbc:mysql://%s:%s/%s?useUnicode=true&characterEncoding=utf8", env.getProperty("RDS_HOSTNAME"), env.getProperty("RDS_PORT"),env.getProperty("RDS_DB_NAME")); log.info("Configuring with 'aws' profile. Overriding DataSource config file properties with environment variables. URL used: " + url); dataSourceProperties.setUrl(url); dataSourceProperties.setUsername(env.getProperty("RDS_USERNAME")); dataSourceProperties.setPassword(env.getProperty("RDS_PASSWORD")); } if (dataSourceProperties.getUrl() == null) { log.error("Your database connection pool configuration is incorrect! The application" + " cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariConfig config = new HikariConfig(); config.setDataSourceClassName(dataSourceProperties.getDriverClassName()); config.addDataSourceProperty("url", dataSourceProperties.getUrl()); if (dataSourceProperties.getUsername() != null) { config.addDataSourceProperty("user", dataSourceProperties.getUsername()); } else { config.addDataSourceProperty("user", ""); // HikariCP doesn't allow null user } if (dataSourceProperties.getPassword() != null) { config.addDataSourceProperty("password", dataSourceProperties.getPassword()); } else { config.addDataSourceProperty("password", ""); // HikariCP doesn't allow null password } //MySQL optimizations, see https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration if ("com.mysql.jdbc.jdbc2.optional.MysqlDataSource".equals(dataSourceProperties.getDriverClassName())) { config.addDataSourceProperty("cachePrepStmts", jHipsterProperties.getDatasource().isCachePrepStmts()); config.addDataSourceProperty("prepStmtCacheSize", jHipsterProperties.getDatasource().getPrepStmtCacheSize()); config.addDataSourceProperty("prepStmtCacheSqlLimit", jHipsterProperties.getDatasource().getPrepStmtCacheSqlLimit()); } if (metricRegistry != null) { config.setMetricRegistry(metricRegistry); } return new HikariDataSource(config); }
/** * PrimefacesFileUploadServletContextInitializer for native uploader, * since {@link FileUploadFilter} suffices for commons file uploader. * @return primefaces file upload servlet context initializer */ @ConditionalOnExpression("'${jsf.primefaces.uploader}' != 'commons'") @Bean public ServletContextInitializer primefacesFileUploadServletContextInitializer() { return new PrimefacesFileUploadServletContextInitializer(this.multipartConfigElement); }
/** * File upload filter is required only if commons fileupload is chosen. * @return file upload filter */ @ConditionalOnExpression("'${jsf.primefaces.uploader}' == 'commons'") @Bean public Filter fileUploadFilter() { return new FileUploadFilter(); }
@ConditionalOnExpression("!${services.fiat.enabled:false}") @Bean AnonymousConfig anonymousConfig() { return new AnonymousConfig(); }
@Bean @ConditionalOnExpression("#{'${" + FeaturesProperties.FEATURES_PREFIX + "." + FeaturesProperties.ANALYTICS_ENABLED + ":true}'.equalsIgnoreCase('false')}") public RedisHealthIndicator redisHealthIndicator() { return new CustomRedisHealthIndicator(redisConnectionFactory); }
@Bean(destroyMethod = "close") @ConditionalOnExpression("#{!environment.acceptsProfiles('cloud') && !environment.acceptsProfiles('heroku')}") public DataSource dataSource(DataSourceProperties dataSourceProperties, JHipsterProperties jHipsterProperties) { log.debug("Configuring Datasource"); if (dataSourceProperties.getUrl() == null) { log.error( "Your database connection pool configuration is incorrect! The application" + " cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariConfig config = new HikariConfig(); config.setDataSourceClassName(dataSourceProperties.getDriverClassName()); config.addDataSourceProperty("url", dataSourceProperties.getUrl()); if (dataSourceProperties.getUsername() != null) { config.addDataSourceProperty("user", dataSourceProperties.getUsername()); } else { config.addDataSourceProperty("user", ""); // HikariCP doesn't allow // null user } if (dataSourceProperties.getPassword() != null) { config.addDataSourceProperty("password", dataSourceProperties.getPassword()); } else { config.addDataSourceProperty("password", ""); // HikariCP doesn't // allow null // password } // MySQL optimizations, see // https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration if ("com.mysql.jdbc.jdbc2.optional.MysqlDataSource".equals(dataSourceProperties.getDriverClassName())) { config.addDataSourceProperty("cachePrepStmts", jHipsterProperties.getDatasource().isCachePrepStmts()); config.addDataSourceProperty("prepStmtCacheSize", jHipsterProperties.getDatasource().getPrepStmtCacheSize()); config.addDataSourceProperty("prepStmtCacheSqlLimit", jHipsterProperties.getDatasource().getPrepStmtCacheSqlLimit()); // config.setIdleTimeout(30000); // config.setMaxLifetime(60000); // config.setConnectionTimeout(9000); config.setMaximumPoolSize(100); } if (metricRegistry != null) { config.setMetricRegistry(metricRegistry); } return new HikariDataSource(config); }
@Bean @ConditionalOnExpression(PERSISTENCE_IS_ENABLED_WITH_EMBEDDED_REDIS) public EmailEmbeddedRedis emailEmbeddedRedis() { return emailEmbeddedRedis; }
@Bean(destroyMethod = "close") @ConditionalOnExpression("#{!environment.acceptsProfiles('cloud') && !environment.acceptsProfiles('heroku')}") public DataSource dataSource(DataSourceProperties dataSourceProperties, JHipsterProperties jHipsterProperties) { log.debug("Configuring Datasource"); String databaseName = env.getProperty("spring.datasource.name"); // Standard property not available in DataSourceProperties if (dataSourceProperties.getUrl() == null && databaseName == null) { log.error("Your database connection pool configuration is incorrect! The application" + " cannot start. Please check your Spring profile, current profiles are: {}", Arrays.toString(env.getActiveProfiles())); throw new ApplicationContextException("Database connection pool is not configured correctly"); } HikariConfig config = new HikariConfig(); config.setDataSourceClassName(dataSourceProperties.getDriverClassName()); if(StringUtils.isEmpty(dataSourceProperties.getUrl())) { config.addDataSourceProperty("databaseName", databaseName); config.addDataSourceProperty("serverName", jHipsterProperties.getDatasource().getServerName()); } else { config.addDataSourceProperty("url", dataSourceProperties.getUrl()); } if (dataSourceProperties.getUsername() != null) { config.addDataSourceProperty("user", dataSourceProperties.getUsername()); } else { config.addDataSourceProperty("user", ""); // HikariCP doesn't allow null user } if (dataSourceProperties.getPassword() != null) { config.addDataSourceProperty("password", dataSourceProperties.getPassword()); } else { config.addDataSourceProperty("password", ""); // HikariCP doesn't allow null password } //MySQL optimizations, see https://github.com/brettwooldridge/HikariCP/wiki/MySQL-Configuration if ("com.mysql.jdbc.jdbc2.optional.MysqlDataSource".equals(dataSourceProperties.getDriverClassName())) { config.addDataSourceProperty("cachePrepStmts", jHipsterProperties.getDatasource().isCachePrepStmts()); config.addDataSourceProperty("prepStmtCacheSize", jHipsterProperties.getDatasource().getPrepStmtCacheSize()); config.addDataSourceProperty("prepStmtCacheSqlLimit", jHipsterProperties.getDatasource().getPrepStmtCacheSqlLimit()); } if (metricRegistry != null) { config.setMetricRegistry(metricRegistry); } return new HikariDataSource(config); }