如何在不破坏Spring Boot配置的情况下启用矩阵变量支持?

时间:2014-07-01 19:57:46

标签: spring-mvc spring-boot

我想使用Spring Boot来利用JacksonAutoConfiguration并为我的控制器启用矩阵变量,这需要调用RequestMappingHandlerMapping.setRemoveSemicolonContent(false)

如果在没有扫描WebMvcConfiguration的情况下运行此trivial Gist,则输出为

{"dateTime":1404244199372}

扫描时,输出为

{"dateTime":{"year":2014,"era":1,"dayOfYear":182,"dayOfWeek":2,"dayOfMonth":1,"centuryOfEra":20,"yearOfEra":2014,"yearOfCentury":14,"weekyear":2014,"monthOfYear":7,"weekOfWeekyear":27,"secondOfDay":76856,"minuteOfDay":1280,"hourOfDay":21,"minuteOfHour":20,"secondOfMinute":56,"millisOfSecond":807,"millisOfDay":76856807,"chronology":{"zone":{"fixed":false,"uncachedZone":{"cachable":true,"fixed":false,"id":"Europe/Berlin"},"id":"Europe/Berlin"}},"zone":{"fixed":false,"uncachedZone":{"cachable":true,"fixed":false,"id":"Europe/Berlin"},"id":"Europe/Berlin"},"millis":1404242456807,"afterNow":false,"beforeNow":true,"equalNow":false}}  

很难说出为什么会发生这种情况,而且在ObjectMapperJodaModuleMappingJackson2HttpMessageConverter中进行挖掘之后我仍然不确定。

知道如何配置Spring以利用Spring Boot并能够支持矩阵变量吗?

更新DelegatingWebMvcConfiguration中扫描导致的其他破坏包括Boot http.mappers.jsonPrettyPrint支持。

2 个答案:

答案 0 :(得分:4)

正如here所述,以下是Spring Boot 1.2的技巧。

wrapper

答案 1 :(得分:0)

我认为您可能只需要从引导自动配置中复制所需的位。或者提出Spring Framework的问题,以获得对WebMvcConfigurer中添加的分号功能的支持。另一件可能正常工作的是直接添加RequestMappingHandlerMapping(而不是使用配置的基类)。