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


Java ConditionalOnProperty類代碼示例

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


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

示例1: messageContainer

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
@Bean
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host")
public SimpleMessageListenerContainer messageContainer() {
    SimpleMessageListenerContainer container =
            new SimpleMessageListenerContainer(connectionFactory);
    container.setQueues(queue());
    container.setExposeListenerChannel(true);
    container.setMaxConcurrentConsumers(2);
    container.setConcurrentConsumers(1);
    //設置確認模式手工確認
    container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
    container.setMessageListener((ChannelAwareMessageListener) (message, channel) -> {
        byte[] messageBody = message.getBody();
        LOGGER.debug("motan 框架接收到的消息");
        //確認消息成功消費
        final Boolean success = mythMqReceiveService.processMessage(messageBody);
        if (success) {
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        }
    });
    return container;
}
 
開發者ID:yu199195,項目名稱:myth,代碼行數:23,代碼來源:AmqpConfig.java

示例2: localDeployers

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
@Bean
@ConditionalOnProperty(value = "spring.cloud.skipper.server.enableLocalPlatform", matchIfMissing = true)
public Platform localDeployers(LocalPlatformProperties localPlatformProperties) {
	List<Deployer> deployers = new ArrayList<>();
	Map<String, LocalDeployerProperties> localDeployerPropertiesMap = localPlatformProperties.getAccounts();
	if (localDeployerPropertiesMap.isEmpty()) {
		localDeployerPropertiesMap.put("default", new LocalDeployerProperties());
	}
	for (Map.Entry<String, LocalDeployerProperties> entry : localDeployerPropertiesMap
			.entrySet()) {
		LocalAppDeployer localAppDeployer = new LocalAppDeployer(entry.getValue());
		Deployer deployer = new Deployer(entry.getKey(), "local", localAppDeployer);
		deployer.setDescription(prettyPrintLocalDeployerProperties(entry.getValue()));
		deployers.add(deployer);
	}

	return new Platform("Local", deployers);
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:19,代碼來源:SkipperServerPlatformConfiguration.java

示例3: casCorsFilter

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
@ConditionalOnProperty(prefix = "cas.httpWebRequest.cors", name = "enabled", havingValue = "true")
@Bean
@RefreshScope
public FilterRegistrationBean casCorsFilter() {
    final HttpWebRequestProperties.Cors cors = casProperties.getHttpWebRequest().getCors();
    final UrlBasedCorsConfigurationSource source = new UrlBasedCorsConfigurationSource();
    final CorsConfiguration config = new CorsConfiguration();
    config.setAllowCredentials(cors.isEnabled());
    config.setAllowedOrigins(cors.getAllowOrigins());
    config.setAllowedMethods(cors.getAllowMethods());
    config.setAllowedHeaders(cors.getAllowHeaders());
    config.setMaxAge(cors.getMaxAge());
    config.setExposedHeaders(cors.getExposedHeaders());
    source.registerCorsConfiguration("/**", config);
    final FilterRegistrationBean bean = new FilterRegistrationBean(new CorsFilter(source));
    bean.setName("casCorsFilter");
    bean.setAsyncSupported(true);
    bean.setOrder(0);
    return bean;
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:21,代碼來源:CasFiltersConfiguration.java

示例4: mqProducer

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
@Bean
@ConditionalOnClass(DefaultMQProducer.class)
@ConditionalOnMissingBean(DefaultMQProducer.class)
@ConditionalOnProperty(prefix = "spring.rocketmq", value = {"nameServer", "producer.group"})
public DefaultMQProducer mqProducer(RocketMQProperties rocketMQProperties) {

    RocketMQProperties.Producer producerConfig = rocketMQProperties.getProducer();
    String groupName = producerConfig.getGroup();
    Assert.hasText(groupName, "[spring.rocketmq.producer.group] must not be null");

    DefaultMQProducer producer = new DefaultMQProducer(producerConfig.getGroup());
    producer.setNamesrvAddr(rocketMQProperties.getNameServer());
    producer.setSendMsgTimeout(producerConfig.getSendMsgTimeout());
    producer.setRetryTimesWhenSendFailed(producerConfig.getRetryTimesWhenSendFailed());
    producer.setRetryTimesWhenSendAsyncFailed(producerConfig.getRetryTimesWhenSendAsyncFailed());
    producer.setMaxMessageSize(producerConfig.getMaxMessageSize());
    producer.setCompressMsgBodyOverHowmuch(producerConfig.getCompressMsgBodyOverHowmuch());
    producer.setRetryAnotherBrokerWhenNotStoreOK(producerConfig.isRetryAnotherBrokerWhenNotStoreOk());

    return producer;
}
 
開發者ID:QianmiOpen,項目名稱:spring-boot-starter-rocketmq,代碼行數:22,代碼來源:RocketMQAutoConfiguration.java

示例5: metricsSchedulingAspect

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
/**
 * If AOP is not enabled, scheduled interception will not work.
 */
@Bean
@ConditionalOnClass(name = "org.aspectj.lang.ProceedingJoinPoint")
@ConditionalOnProperty(value = "spring.aop.enabled", havingValue = "true", matchIfMissing = true)
public ScheduledMethodMetrics metricsSchedulingAspect(MeterRegistry registry) {
    return new ScheduledMethodMetrics(registry);
}
 
開發者ID:micrometer-metrics,項目名稱:micrometer,代碼行數:10,代碼來源:MetricsAutoConfiguration.java

示例6: ClientConfiguration

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
/**
 * S3 儲存客戶端
 *
 * @return 客戶端
 */
@Bean
@ConditionalOnProperty(value = "bigbug.storage.s3.enable", havingValue = "true")
AmazonS3Client amazonS3Client() {
    ClientConfiguration clientConfig = new ClientConfiguration();
    clientConfig.setProtocol(Protocol.HTTP);

    BasicAWSCredentials basicAWSCredentials =
            new BasicAWSCredentials(
                    storageProperties.getStorage().getS3().getAccessKey(),
                    storageProperties.getStorage().getS3().getSecretKey());

    return (AmazonS3Client) AmazonS3ClientBuilder.standard()
            .withClientConfiguration(clientConfig)
            .withEndpointConfiguration(
                    new AwsClientBuilder.EndpointConfiguration(
                            storageProperties.getStorage().getS3().getEndpoint(), Regions.DEFAULT_REGION.getName()))
            .withCredentials(new AWSStaticCredentialsProvider(basicAWSCredentials))
            .build();
}
 
開發者ID:bigbug-studio,項目名稱:generator-jhipster-storage,代碼行數:25,代碼來源:_StorageConfiguration.java

示例7: messageContainer

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
@Bean
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host")
public SimpleMessageListenerContainer messageContainer() {
    SimpleMessageListenerContainer container =
            new SimpleMessageListenerContainer(connectionFactory);
    container.setQueues(queue());
    container.setExposeListenerChannel(true);
    container.setMaxConcurrentConsumers(1);
    container.setConcurrentConsumers(1);
    //設置確認模式手工確認
    container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
    container.setMessageListener((ChannelAwareMessageListener) (message, channel) -> {
        byte[] messageBody = message.getBody();
        //確認消息成功消費
        final Boolean success = mythMqReceiveService.processMessage(messageBody);
        if (success) {
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        }
    });
    return container;
}
 
開發者ID:yu199195,項目名稱:myth,代碼行數:22,代碼來源:AmqpConfig.java

示例8: jmsListenerContainerQueue

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
@Bean(name = "queueListenerContainerFactory")
@ConditionalOnProperty(prefix = "spring.activemq", name = "broker-url")
public JmsListenerContainerFactory<?> jmsListenerContainerQueue(ConnectionFactory activeMQConnectionFactory) {
    DefaultJmsListenerContainerFactory bean = new DefaultJmsListenerContainerFactory();
    bean.setConnectionFactory(activeMQConnectionFactory);
    bean.setPubSubDomain(Boolean.FALSE);
    return bean;
}
 
開發者ID:yu199195,項目名稱:myth,代碼行數:9,代碼來源:JmsConfig.java

示例9: messageContainer

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
@Bean
@ConditionalOnProperty(prefix = "spring.rabbitmq", name = "host")
public SimpleMessageListenerContainer messageContainer() {
    SimpleMessageListenerContainer container =
            new SimpleMessageListenerContainer(connectionFactory);
    container.setQueues(queue());
    container.setExposeListenerChannel(true);
    container.setMaxConcurrentConsumers(3);
    container.setConcurrentConsumers(1);
    //設置確認模式手工確認
    container.setAcknowledgeMode(AcknowledgeMode.MANUAL);
    container.setMessageListener((ChannelAwareMessageListener) (message, channel) -> {
        byte[] messageBody = message.getBody();
        LogUtil.debug(LOGGER,()->"springcloud  account服務  amqp接收消息");
        //確認消息成功消費
        final Boolean success = mythMqReceiveService.processMessage(messageBody);
        if (success) {
            channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
        }
    });
    return container;
}
 
開發者ID:yu199195,項目名稱:myth,代碼行數:23,代碼來源:AmqpConfig.java

示例10: SpectatorMetricReader

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricReader
public SpectatorMetricReader SpectatorMetricReader(Registry registry) {
    log.info("Initializing Spectator Metrics Log reporting");
    return new SpectatorMetricReader(registry);
}
 
開發者ID:oktadeveloper,項目名稱:jhipster-microservices-example,代碼行數:8,代碼來源:MetricsConfiguration.java

示例11: blueKitResetPasswordPolicy

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
@Bean("blueKitResetPasswordPolicy")
@ConditionalOnBean(ResetPasswordPolicy.class)
@ConditionalOnProperty(prefix = "blue-kit.b2c.policy.edit-profile", value = {"name", "redirect-url"})
@ConfigurationProperties("blue-kit.b2c.policy.reset-password")
public ResetPasswordPolicy blueKitResetPasswordPolicy(){

    return new ResetPasswordPolicy();
}
 
開發者ID:Xitikit,項目名稱:xitikit-blue,代碼行數:9,代碼來源:B2CPolicyAutoConfiguration.java

示例12: ticketRegistryCleanerScheduler

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
@ConditionalOnMissingBean(name = "ticketRegistryCleanerScheduler")
@ConditionalOnProperty(prefix = "cas.ticket.registry.cleaner", name = "enabled", havingValue = "true", matchIfMissing = true)
@Bean
@Autowired
@RefreshScope
public TicketRegistryCleanerScheduler ticketRegistryCleanerScheduler(@Qualifier("ticketRegistryCleaner") 
                                                                     final TicketRegistryCleaner ticketRegistryCleaner) {
    return new TicketRegistryCleanerScheduler(ticketRegistryCleaner);
}
 
開發者ID:mrluo735,項目名稱:cas-5.1.0,代碼行數:10,代碼來源:CasCoreTicketsSchedulingConfiguration.java

示例13: dataSourceInitializer4

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
@Bean
@ConditionalOnProperty(name = "spring.datasource4.url")
@ConfigurationProperties(prefix = "spring.datasource4")
public DataSourceInitializer dataSourceInitializer4(DataSourceProperties properties,
		ApplicationContext applicationContext) {
	return new DataSourceInitializer(properties, applicationContext, 4);
}
 
開發者ID:muxiangqiu,項目名稱:spring-boot-multidatasource,代碼行數:8,代碼來源:DataSourceAutoConfiguration.java

示例14: spectatorMetricReader

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
@Bean
@ConditionalOnProperty("jhipster.logging.spectator-metrics.enabled")
@ExportMetricReader
public SpectatorMetricReader spectatorMetricReader(Registry registry) {
    log.info("Initializing Spectator Metrics Log reporting");
    return new SpectatorMetricReader(registry);
}
 
開發者ID:xm-online,項目名稱:xm-ms-balance,代碼行數:8,代碼來源:MetricsConfiguration.java

示例15: amqpMessagingSpanManager

import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; //導入依賴的package包/類
@Bean
@ConditionalOnProperty(value = "spring.sleuth.amqp.enabled", matchIfMissing = true)
@ConditionalOnMissingBean(AmqpMessagingSpanManager.class)
public AmqpMessagingSpanManager amqpMessagingSpanManager(
    AmqpMessagingSpanInjector amqpMessagingSpanInjector,
    AmqpMessagingSpanExtractor amqpMessagingSpanExtractor,
    Tracer tracer) {
  return new DefaultAmqpMessagingSpanManager(
      amqpMessagingSpanInjector, amqpMessagingSpanExtractor, tracer);
}
 
開發者ID:netshoes,項目名稱:spring-cloud-sleuth-amqp-starter,代碼行數:11,代碼來源:SleuthAmqpMessagingAutoConfiguration.java


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