當前位置: 首頁>>代碼示例>>Java>>正文


Java ConditionalOnExpression類代碼示例

本文整理匯總了Java中org.springframework.boot.autoconfigure.condition.ConditionalOnExpression的典型用法代碼示例。如果您正苦於以下問題:Java ConditionalOnExpression類的具體用法?Java ConditionalOnExpression怎麽用?Java ConditionalOnExpression使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ConditionalOnExpression類屬於org.springframework.boot.autoconfigure.condition包,在下文中一共展示了ConditionalOnExpression類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: dataSource

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@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);
}
 
開發者ID:VHAINNOVATIONS,項目名稱:BCDS,代碼行數:30,代碼來源:DatabaseConfiguration.java

示例2: dataSource

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@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;
}
 
開發者ID:xetys,項目名稱:jhipster-ribbon-hystrix,代碼行數:27,代碼來源:DatabaseConfiguration.java

示例3: dataSource

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@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);
}
 
開發者ID:ServiceCutter,項目名稱:ServiceCutter,代碼行數:27,代碼來源:DatabaseConfiguration.java

示例4: dataSource

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@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);
}
 
開發者ID:priitl,項目名稱:p2p-webtv,代碼行數:20,代碼來源:DatabaseConfiguration.java

示例5: dataSource

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@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);
}
 
開發者ID:GastonMauroDiaz,項目名稱:buenojo,代碼行數:31,代碼來源:DatabaseConfiguration.java

示例6: tenantVerifyInterceptor

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@Bean
@Order(2)
@ConditionalOnExpression("${xm-config.enabled} && ${tenant.reject-suspended:true}")
TenantVerifyInterceptor tenantVerifyInterceptor(TenantListRepository tenantListRepository,
                                                TenantContextHolder tenantContextHolder) {
    return new TenantVerifyInterceptor(tenantListRepository, tenantContextHolder);
}
 
開發者ID:xm-online,項目名稱:xm-commons,代碼行數:8,代碼來源:XmMsWebConfiguration.java

示例7: dataSource

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@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);
}
 
開發者ID:quanticc,項目名稱:ugc-bot-redux,代碼行數:40,代碼來源:DatabaseConfiguration.java

示例8: grpcInprocessServerRunner

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@Bean
@ConditionalOnExpression("#{environment.getProperty('grpc.inProcessServerName','')!=''}")
public GRpcServerRunner grpcInprocessServerRunner(GRpcServerBuilderConfigurer configurer){
    return new GRpcServerRunner(configurer, InProcessServerBuilder.forName(grpcServerProperties.getInProcessServerName()));
}
 
開發者ID:LogNet,項目名稱:grpc-spring-boot-starter,代碼行數:6,代碼來源:GRpcAutoConfiguration.java

示例9: addUnrestrictedUser

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@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;
}
 
開發者ID:spinnaker,項目名稱:fiat,代碼行數:9,代碼來源:UnrestrictedResourceConfig.java

示例10: dataSource

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@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') { _%>
 
開發者ID:xetys,項目名稱:jhipster-ribbon-hystrix,代碼行數:28,代碼來源:_DatabaseConfiguration.java

示例11: dataSource

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@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);
}
 
開發者ID:arhs-cube-gameofcode,項目名稱:gameofcode,代碼行數:37,代碼來源:DatabaseConfiguration.java

示例12: deploymentIdRepository

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@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);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-dataflow,代碼行數:9,代碼來源:FeaturesConfiguration.java

示例13: dataSource

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@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);
}
 
開發者ID:gmarziou,項目名稱:jhipster-ionic,代碼行數:34,代碼來源:DatabaseConfiguration.java

示例14: dataSource

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@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);
}
 
開發者ID:josedab,項目名稱:angularjs-springboot-bookstore,代碼行數:28,代碼來源:DatabaseConfiguration.java

示例15: dataSource

import org.springframework.boot.autoconfigure.condition.ConditionalOnExpression; //導入依賴的package包/類
@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);
}
 
開發者ID:josedab,項目名稱:spring-boot-angularjs-examples,代碼行數:28,代碼來源:DatabaseConfiguration.java


注:本文中的org.springframework.boot.autoconfigure.condition.ConditionalOnExpression類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。