本文整理汇总了Java中org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter类的典型用法代码示例。如果您正苦于以下问题:Java TypeConstrainedMappingJackson2HttpMessageConverter类的具体用法?Java TypeConstrainedMappingJackson2HttpMessageConverter怎么用?Java TypeConstrainedMappingJackson2HttpMessageConverter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeConstrainedMappingJackson2HttpMessageConverter类属于org.springframework.hateoas.mvc包,在下文中一共展示了TypeConstrainedMappingJackson2HttpMessageConverter类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: customizedSupportedMediaTypes
import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; //导入依赖的package包/类
@PostConstruct
public void customizedSupportedMediaTypes() {
if (this.beanFactory instanceof ListableBeanFactory) {
Map<String, RequestMappingHandlerAdapter> handlerAdapters = ((ListableBeanFactory) this.beanFactory)
.getBeansOfType(RequestMappingHandlerAdapter.class);
for (Entry<String, RequestMappingHandlerAdapter> entry : handlerAdapters
.entrySet()) {
RequestMappingHandlerAdapter handlerAdapter = entry.getValue();
for (HttpMessageConverter<?> converter : handlerAdapter
.getMessageConverters()) {
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
((TypeConstrainedMappingJackson2HttpMessageConverter) converter)
.setSupportedMediaTypes(
Arrays.asList(MediaTypes.HAL_JSON,
MediaType.APPLICATION_JSON));
}
}
}
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:22,代码来源:HypermediaHttpMessageConverterConfiguration.java
示例2: customizationOfSupportedMediaTypesCanBeDisabled
import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; //导入依赖的package包/类
@Test
public void customizationOfSupportedMediaTypesCanBeDisabled() {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(BaseConfig.class);
EnvironmentTestUtils.addEnvironment(this.context,
"spring.hateoas.use-hal-as-default-json-media-type:false");
this.context.refresh();
RequestMappingHandlerAdapter handlerAdapter = this.context
.getBean(RequestMappingHandlerAdapter.class);
for (HttpMessageConverter<?> converter : handlerAdapter.getMessageConverters()) {
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
assertThat(converter.getSupportedMediaTypes())
.containsExactly(MediaTypes.HAL_JSON);
}
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:18,代码来源:HypermediaAutoConfigurationTests.java
示例3: customizationOfSupportedMediaTypesCanBeDisabled
import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; //导入依赖的package包/类
@Test
public void customizationOfSupportedMediaTypesCanBeDisabled() {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(BaseConfig.class);
EnvironmentTestUtils.addEnvironment(this.context,
"spring.hateoas.use-hal-as-default-json-media-type:false");
this.context.refresh();
RequestMappingHandlerAdapter handlerAdapter = this.context
.getBean(RequestMappingHandlerAdapter.class);
for (HttpMessageConverter<?> converter : handlerAdapter.getMessageConverters()) {
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
assertThat(converter.getSupportedMediaTypes(),
contains(MediaTypes.HAL_JSON));
}
}
}
开发者ID:Nephilim84,项目名称:contestparser,代码行数:18,代码来源:HypermediaAutoConfigurationTests.java
示例4: supportedMediaTypesOfTypeConstrainedConvertersIsCustomized
import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; //导入依赖的package包/类
@Test
public void supportedMediaTypesOfTypeConstrainedConvertersIsCustomized() {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(BaseConfig.class);
this.context.refresh();
RequestMappingHandlerAdapter handlerAdapter = this.context
.getBean(RequestMappingHandlerAdapter.class);
for (HttpMessageConverter<?> converter : handlerAdapter.getMessageConverters()) {
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
assertThat(converter.getSupportedMediaTypes())
.contains(MediaType.APPLICATION_JSON, MediaTypes.HAL_JSON);
}
}
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:16,代码来源:HypermediaAutoConfigurationTests.java
示例5: getHalMessageConverter
import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; //导入依赖的package包/类
private HttpMessageConverter getHalMessageConverter() {
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.registerModule(new Jackson2HalModule());
MappingJackson2HttpMessageConverter halConverter = new TypeConstrainedMappingJackson2HttpMessageConverter(Resource.class);
halConverter.setSupportedMediaTypes(Arrays.asList(MediaTypes.HAL_JSON));
halConverter.setObjectMapper(objectMapper);
return halConverter;
}
开发者ID:EMBL-EBI-SUBS-OLD,项目名称:subs,代码行数:10,代码来源:StressTesterConfig.java
示例6: correctJacksonConverter
import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; //导入依赖的package包/类
private void correctJacksonConverter(ObjectMapper objectMapper,
TypeConstrainedMappingJackson2HttpMessageConverter halJacksonHttpMessageConverter,
RestTemplate restTemplate) {
Stream<HttpMessageConverter<?>> jacksonConverters = restTemplate.getMessageConverters().stream().filter(httpMessageConverter -> {
return MappingJackson2HttpMessageConverter.class.isAssignableFrom(httpMessageConverter.getClass());
});
jacksonConverters.forEach(httpMessageConverter -> ((MappingJackson2HttpMessageConverter) httpMessageConverter).setObjectMapper(objectMapper));
restTemplate.getMessageConverters().add(halJacksonHttpMessageConverter);
}
开发者ID:thomasletsch,项目名称:moserp,代码行数:10,代码来源:TestRestConfiguration.java
示例7: supportedMediaTypesOfTypeConstrainedConvertersIsCustomized
import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; //导入依赖的package包/类
@Test
public void supportedMediaTypesOfTypeConstrainedConvertersIsCustomized() {
this.context = new AnnotationConfigWebApplicationContext();
this.context.setServletContext(new MockServletContext());
this.context.register(BaseConfig.class);
this.context.refresh();
RequestMappingHandlerAdapter handlerAdapter = this.context
.getBean(RequestMappingHandlerAdapter.class);
for (HttpMessageConverter<?> converter : handlerAdapter.getMessageConverters()) {
if (converter instanceof TypeConstrainedMappingJackson2HttpMessageConverter) {
assertThat(converter.getSupportedMediaTypes(), containsInAnyOrder(
MediaType.APPLICATION_JSON, MediaTypes.HAL_JSON));
}
}
}
开发者ID:Nephilim84,项目名称:contestparser,代码行数:16,代码来源:HypermediaAutoConfigurationTests.java
示例8: typeConstrainedConverter
import org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter; //导入依赖的package包/类
@Bean
public TypeConstrainedMappingJackson2HttpMessageConverter typeConstrainedConverter() {
return new TypeConstrainedMappingJackson2HttpMessageConverter(
ResourceSupport.class);
}
开发者ID:vikrammane23,项目名称:https-github.com-g0t4-jenkins2-course-spring-boot,代码行数:6,代码来源:HttpMessageConvertersAutoConfigurationTests.java
注:本文中的org.springframework.hateoas.mvc.TypeConstrainedMappingJackson2HttpMessageConverter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论