本文整理汇总了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;
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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();
}
示例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);
}
示例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);
}
示例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);
}
示例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