Last active
August 29, 2015 14:03
-
-
Save emersonf/a5bec01225f540b1a167 to your computer and use it in GitHub Desktop.
Jackson Joda DateTime serialisation from Spring Boot breaks with DelegatingWebMvcConfiguration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
@EnableAutoConfiguration | |
@ComponentScan("internal.sandbox") | |
public class Application { | |
public static void main(String[] args) { | |
new SpringApplicationBuilder(Application.class).run(args); | |
} | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Foo { | |
private DateTime dateTime; | |
public DateTime getDateTime() { | |
return dateTime; | |
} | |
public void setDateTime(DateTime dateTime) { | |
this.dateTime = dateTime; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<parent> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-parent</artifactId> | |
<version>1.1.3.RELEASE</version> | |
</parent> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>internal</groupId> | |
<artifactId>sandbox-spring-boot</artifactId> | |
<version>1.0.0</version> | |
<dependencies> | |
<dependency> | |
<groupId>com.fasterxml.jackson.datatype</groupId> | |
<artifactId>jackson-datatype-joda</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>joda-time</groupId> | |
<artifactId>joda-time</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-jetty</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-web</artifactId> | |
<exclusions> | |
<exclusion> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-tomcat</artifactId> | |
</exclusion> | |
</exclusions> | |
</dependency> | |
</dependencies> | |
</project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RestController | |
public class SampleController { | |
@RequestMapping(value = "/foo") | |
public Foo getFoo() { | |
Foo foo = new Foo(); | |
foo.setDateTime(DateTime.now()); | |
return foo; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Configuration | |
public class WebMvcConfiguration extends DelegatingWebMvcConfiguration { | |
@Override | |
@Bean | |
public RequestMappingHandlerMapping requestMappingHandlerMapping() { | |
RequestMappingHandlerMapping mapping = super.requestMappingHandlerMapping(); | |
mapping.setRemoveSemicolonContent(false); | |
return mapping; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment