本文整理匯總了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