当前位置: 首页>>代码示例>>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;未经允许,请勿转载。