本文整理汇总了Java中org.springframework.messaging.converter.MappingJackson2MessageConverter.setObjectMapper方法的典型用法代码示例。如果您正苦于以下问题:Java MappingJackson2MessageConverter.setObjectMapper方法的具体用法?Java MappingJackson2MessageConverter.setObjectMapper怎么用?Java MappingJackson2MessageConverter.setObjectMapper使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.messaging.converter.MappingJackson2MessageConverter
的用法示例。
在下文中一共展示了MappingJackson2MessageConverter.setObjectMapper方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createPayloadArgumentCompositeConverter
import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
private CompositeMessageConverter createPayloadArgumentCompositeConverter() {
List<MessageConverter> payloadArgumentConverters = new ArrayList<>();
if (JACKSON_2_PRESENT) {
MappingJackson2MessageConverter jacksonMessageConverter = new MappingJackson2MessageConverter();
jacksonMessageConverter.setObjectMapper(Jackson2ObjectMapperBuilder.json().build());
jacksonMessageConverter.setSerializedPayloadClass(String.class);
jacksonMessageConverter.setStrictContentTypeMatch(true);
payloadArgumentConverters.add(jacksonMessageConverter);
}
ObjectMessageConverter objectMessageConverter = new ObjectMessageConverter();
objectMessageConverter.setStrictContentTypeMatch(true);
payloadArgumentConverters.add(objectMessageConverter);
payloadArgumentConverters.add(new SimpleMessageConverter());
return new CompositeMessageConverter(payloadArgumentConverters);
}
示例2: initMessageConverter
import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
protected void initMessageConverter(MessageConverter messageConverter) {
StringMessageConverter stringMessageConverter = new StringMessageConverter();
stringMessageConverter.setSerializedPayloadClass(String.class);
List<MessageConverter> messageConverters = new ArrayList<>();
messageConverters.add(stringMessageConverter);
if (messageConverter != null) {
messageConverters.add(messageConverter);
} else if (JACKSON_2_PRESENT) {
MappingJackson2MessageConverter mappingJackson2MessageConverter = new MappingJackson2MessageConverter();
mappingJackson2MessageConverter.setObjectMapper(Jackson2ObjectMapperBuilder.json().build());
mappingJackson2MessageConverter.setSerializedPayloadClass(String.class);
messageConverters.add(mappingJackson2MessageConverter);
}
setMessageConverter(new CompositeMessageConverter(messageConverters));
}
开发者ID:spring-cloud,项目名称:spring-cloud-aws,代码行数:20,代码来源:AbstractMessageChannelMessagingSendingTemplate.java
示例3: instantiation_WithCustomJacksonConverterThatSupportsJava8Types_shouldConvertMessageToString
import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
@Test
public void instantiation_WithCustomJacksonConverterThatSupportsJava8Types_shouldConvertMessageToString() throws IOException {
// Arrange
AmazonSQSAsync amazonSqs = createAmazonSqs();
ObjectMapper objectMapper = Jackson2ObjectMapperBuilder.json().build();
MappingJackson2MessageConverter simpleMessageConverter = new MappingJackson2MessageConverter();
simpleMessageConverter.setSerializedPayloadClass(String.class);
simpleMessageConverter.setObjectMapper(objectMapper);
QueueMessagingTemplate queueMessagingTemplate = new QueueMessagingTemplate(amazonSqs, (ResourceIdResolver) null, simpleMessageConverter);
// Act
queueMessagingTemplate.convertAndSend("test", new TestPerson("Agim", "Emruli", LocalDate.of(2017, 1, 1)));
// Assert
ArgumentCaptor<SendMessageRequest> sendMessageRequestArgumentCaptor = ArgumentCaptor.forClass(SendMessageRequest.class);
verify(amazonSqs).sendMessage(sendMessageRequestArgumentCaptor.capture());
TestPerson testPerson = objectMapper.readValue(sendMessageRequestArgumentCaptor.getValue().getMessageBody(), TestPerson.class);
assertEquals("Agim", testPerson.getFirstName());
assertEquals("Emruli", testPerson.getLastName());
assertEquals(LocalDate.of(2017, 1, 1), testPerson.getActiveSince());
}
示例4: createJacksonConverter
import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
@Override
protected MappingJackson2MessageConverter createJacksonConverter() {
MappingJackson2MessageConverter messageConverter = super.createJacksonConverter();
// Use Jackson builder in order to have JSR-310 and Joda-Time modules registered automatically
messageConverter.setObjectMapper(Jackson2ObjectMapperBuilder.json()
.applicationContext(this.getApplicationContext()).build());
return messageConverter;
}
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:9,代码来源:WebSocketMessageBrokerConfigurationSupport.java
示例5: configureMessageConverters
import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
@Override
public boolean configureMessageConverters(
List<MessageConverter> messageConverters) {
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
converter.setObjectMapper(this.objectMapper);
DefaultContentTypeResolver resolver = new DefaultContentTypeResolver();
resolver.setDefaultMimeType(MimeTypeUtils.APPLICATION_JSON);
converter.setContentTypeResolver(resolver);
messageConverters.add(new StringMessageConverter());
messageConverters.add(new ByteArrayMessageConverter());
messageConverters.add(converter);
return false;
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:14,代码来源:WebSocketMessagingAutoConfiguration.java
示例6: configureMessageConverters
import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
@Override
public boolean configureMessageConverters(
List<MessageConverter> messageConverters) {
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
converter.setObjectMapper(this.objectMapper);
DefaultContentTypeResolver resolver = new DefaultContentTypeResolver();
resolver.setDefaultMimeType(MimeTypeUtils.APPLICATION_JSON);
converter.setContentTypeResolver(resolver);
messageConverters.add(converter);
return true;
}
示例7: configureMessageConverters
import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
@Override
public boolean configureMessageConverters(List<MessageConverter> messageConverters) {
// Workaround for issue 2445: https://github.com/spring-projects/spring-boot/issues/2445
DefaultContentTypeResolver resolver = new DefaultContentTypeResolver();
resolver.setDefaultMimeType(MimeTypeUtils.APPLICATION_JSON);
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
converter.setObjectMapper(objectMapper);
converter.setContentTypeResolver(resolver);
messageConverters.add(converter);
return false;
}
示例8: createJacksonConverter
import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
@Override
protected MappingJackson2MessageConverter createJacksonConverter() {
DefaultContentTypeResolver contentTypeResolver = new DefaultContentTypeResolver();
contentTypeResolver.setDefaultMimeType(MimeTypeUtils.APPLICATION_JSON);
MappingJackson2MessageConverter msgConv = new MappingJackson2MessageConverter();
msgConv.setContentTypeResolver(contentTypeResolver);
msgConv.setObjectMapper(this.objMapper);
return msgConv;
}
示例9: configureMessageConverters
import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
@Override
public boolean configureMessageConverters(final List<MessageConverter> messageConverters) {
DefaultContentTypeResolver resolver = new DefaultContentTypeResolver();
resolver.setDefaultMimeType(MimeTypeUtils.APPLICATION_JSON);
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
converter.setObjectMapper(objectMapper);
converter.setContentTypeResolver(resolver);
messageConverters.add(converter);
return false;
}
示例10: configureMessageConverters
import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
@Override
public boolean configureMessageConverters(List<MessageConverter> converters) {
MappingJackson2MessageConverter jacksonConverter = new MappingJackson2MessageConverter();
jacksonConverter.setObjectMapper(objectMapper);
converters.add(jacksonConverter);
return true;
}
示例11: jackson2Converter
import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
@Bean
public MappingJackson2MessageConverter jackson2Converter() {
MappingJackson2MessageConverter converter = new MappingJackson2MessageConverter();
converter.setObjectMapper(mapper());
return converter;
}
示例12: mappingJackson2MessageConverter
import org.springframework.messaging.converter.MappingJackson2MessageConverter; //导入方法依赖的package包/类
@Bean
public MappingJackson2MessageConverter mappingJackson2MessageConverter() {
MappingJackson2MessageConverter messageConverter = new MappingJackson2MessageConverter();
messageConverter.setObjectMapper(jacksonObjectMapper);
return messageConverter;
}