Skip to content

Instantly share code, notes, and snippets.

@leon
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leon/5913ced04e88fe7ce87f to your computer and use it in GitHub Desktop.
Save leon/5913ced04e88fe7ce87f to your computer and use it in GitHub Desktop.
Gradle config for spring data fowler and java 8 dates
spring.jackson:
dateFormat: com.fasterxml.jackson.databind.util.ISO8601DateFormat
serialization:
writeDatesAsTimestamps: false
buildscript {
ext {
springBootVersion = '1.2.3.RELEASE'
}
repositories {
jcenter()
}
dependencies {
classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
classpath("io.spring.gradle:dependency-management-plugin:0.4.1.RELEASE")
}
}
apply plugin: 'java'
apply plugin: 'idea'
apply plugin: 'spring-boot'
apply plugin: 'io.spring.dependency-management'
jar {
baseName = 'test'
version = '1.0.0'
}
sourceCompatibility = 1.8
targetCompatibility = 1.8
dependencyManagement {
// applyMavenExclusions will not be needed soon https://github.com/spring-gradle-plugins/dependency-management-plugin/issues/47
applyMavenExclusions false
imports {
mavenBom "org.springframework.boot:spring-boot-starter-parent:${springBootVersion}"
}
}
ext['spring-data-releasetrain.version'] = 'Fowler-RELEASE'
dependencies {
compile('org.springframework.boot:spring-boot-starter-actuator')
compile('org.springframework.boot:spring-boot-starter-web')
compile('org.springframework.boot:spring-boot-starter-data-jpa')
// Included so that jackson serializes dates properly
compile('com.fasterxml.jackson.datatype:jackson-datatype-jsr310')
}
package test;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.orm.jpa.EntityScan;
import org.springframework.data.jpa.convert.threeten.Jsr310JpaConverters;
@SpringBootApplication
// Enable java 8 dates in hibernate
@EntityScan(basePackageClasses = { MyApplication.class, Jsr310JpaConverters.class })
public class MyApplication {
public static void main(String[] args) {
SpringApplication.run(MyApplication.class, args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment