Skip to content

Instantly share code, notes, and snippets.

@tungd
Last active February 12, 2019 06:32
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 tungd/5c6503eddcaf651ff88cc202254b3606 to your computer and use it in GitHub Desktop.
Save tungd/5c6503eddcaf651ff88cc202254b3606 to your computer and use it in GitHub Desktop.
Configuration file for microservice using Gradle, Spring Boot, Spring Cloud, Spring Webflux, Srping Data JPA, OpenJPA (for entity class generation)
group = "com.tungdao.sample"
extra["spring.version"] = "5.1.3.RELEASE"
extra["spring.boot.version"] = "2.1.1.RELEASE"
extra["spring.cloud.version"] = "Greenwich.RC2"
plugins {
java
idea
id("org.springframework.boot") version "2.1.1.RELEASE"
id("io.spring.dependency-management") version "1.0.6.RELEASE"
jacoco
id("org.sonarqube") version "2.6.2"
}
repositories {
jcenter()
maven("https://repo.spring.io/milestone")
}
dependencies {
implementation(enforcedPlatform("org.springframework.cloud:spring-cloud-dependencies:${extra["spring.cloud.version"]}"))
implementation("javax.inject:javax.inject:1")
implementation("org.springframework.boot:spring-boot-starter-webflux")
implementation("org.springframework.boot:spring-boot-starter-data-jpa")
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-actuator")
implementation("org.springframework.cloud:spring-cloud-starter-security")
implementation("org.springframework.cloud:spring-cloud-starter-kubernetes")
implementation("org.springframework.cloud:spring-cloud-kubernetes-config")
implementation("org.springframework.cloud:spring-cloud-starter-zipkin")
implementation("com.github.gavlyukovskiy:p6spy-spring-boot-starter:1.5.1")
implementation("com.google.guava:guava:26.0-jre")
implementation("org.flywaydb:flyway-core")
implementation("org.postgresql:postgresql")
compile("org.projectlombok:lombok")
annotationProcessor("org.projectlombok:lombok")
compile("org.mapstruct:mapstruct:1.3.0.Beta2")
annotationProcessor("org.mapstruct:mapstruct-processor:1.3.0.Beta2")
testImplementation("org.springframework.boot:spring-boot-starter-test") {
exclude(module = "junit")
}
testImplementation("org.springframework.security:spring-security-test")
testImplementation("org.junit.jupiter:junit-jupiter-engine")
testImplementation("com.h2database:h2")
testImplementation("uk.co.jemos.podam:podam:7.2.1.RELEASE")
val jpa = configurations.create("jpa")
jpa("org.apache.openjpa:openjpa-all:2.3.0")
jpa("org.postgresql:postgresql")
}
tasks {
test {
useJUnitPlatform()
systemProperty("spring.profiles.active", "test")
testLogging {
events("passed", "skipped", "failed")
showExceptions = true
showCauses = true
}
}
register<JavaExec>("genSchema") {
classpath = configurations["jpa"]
main = "org.apache.openjpa.jdbc.schema.SchemaTool"
args = mutableListOf(
"-properties", "config/openjpa.xml",
"-action", "reflect",
"-file", "build/schema.xml"
)
}
register<JavaExec>("genEntity") {
dependsOn("genSchema")
classpath = configurations["jpa"]
main = "org.apache.openjpa.jdbc.meta.ReverseMappingTool"
args = mutableListOf(
"-properties", "config/openjpa.xml",
"-metadata", "none",
"-annotations", "true",
"-nullableAsObject", "true",
"-useGenericCollections", "true",
"-directory", "build/entity",
"-pkg", "${project.group}.${project.name}.entity",
"build/schema.xml"
)
}
}
<?xml version="1.0"?>
<persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version="1.0">
<persistence-unit name="default">
<properties>
<property name="openjpa.ConnectionURL" value="jdbc:postgresql://localhost:5432/postgres"/>
<property name="openjpa.ConnectionDriverName" value="org.postgresql.Driver"/>
<property name="openjpa.ConnectionUserName" value="postgres"/>
<property name="openjpa.ConnectionPassword" value="postgres"/>
<property name="openjpa.Log" value="DefaultLevel=WARN, Tool=INFO"/>
</properties>
</persistence-unit>
</persistence>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment