Upgrade to Spring Boot 2.7.1
- Fix H2 database support with Spring Boot 2.7+ - Upgrade Gradle, Kotlin, Spring Mockk as well - Upate README.adoc accordingly Closes gh-60 Closes gh-61
This commit is contained in:
28
README.adoc
28
README.adoc
@@ -82,11 +82,11 @@ In order to be able to use Kotlin non-nullable properties with JPA, https://kotl
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
kotlin("plugin.jpa") version "1.4.32"
|
||||
id("org.springframework.boot") version "2.4.4"
|
||||
kotlin("plugin.jpa") version "1.6.21"
|
||||
id("org.springframework.boot") version "2.7.1"
|
||||
id("io.spring.dependency-management") version "1.0.11.RELEASE"
|
||||
kotlin("jvm") version "1.4.32"
|
||||
kotlin("plugin.spring") version "1.4.32"
|
||||
kotlin("jvm") version "1.6.21"
|
||||
kotlin("plugin.spring") version "1.6.21"
|
||||
}
|
||||
----
|
||||
|
||||
@@ -98,15 +98,12 @@ Although Java does not allow one to express null-safety in its type-system, Spri
|
||||
|
||||
This feature can be enabled by adding the `-Xjsr305` compiler flag with the `strict` options.
|
||||
|
||||
Notice also that Kotlin compiler is configured to generate Java 8 bytecode (Java 6 by default).
|
||||
|
||||
`build.gradle.kts`
|
||||
[source,kotlin]
|
||||
----
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs = listOf("-Xjsr305=strict")
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
----
|
||||
@@ -135,6 +132,15 @@ dependencies {
|
||||
}
|
||||
----
|
||||
|
||||
Recent version of H2 requiring special configuration to properly escape reserved keywords like `user`.
|
||||
|
||||
`src/main/resources/application.properties`
|
||||
[source,properties]
|
||||
----
|
||||
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
|
||||
spring.jpa.properties.hibernate.globally_quoted_identifiers_skip_column_definitions = true
|
||||
----
|
||||
|
||||
Spring Boot Gradle plugin automatically uses the Kotlin version declared via the Kotlin Gradle plugin.
|
||||
|
||||
You can now take a <<understanding-generated-app, deeper look at the generated application>>.
|
||||
@@ -423,7 +429,7 @@ Instead of using util classes with abstract methods like in Java, it is usual in
|
||||
`src/main/kotlin/com/example/blog/Extensions.kt`
|
||||
[source,kotlin]
|
||||
----
|
||||
fun LocalDateTime.format() = this.format(englishDateFormatter)
|
||||
fun LocalDateTime.format(): String = this.format(englishDateFormatter)
|
||||
|
||||
private val daysLookup = (1..31).associate { it.toLong() to getOrdinal(it) }
|
||||
|
||||
@@ -443,7 +449,7 @@ private fun getOrdinal(n: Int) = when {
|
||||
else -> "${n}th"
|
||||
}
|
||||
|
||||
fun String.toSlug() = toLowerCase()
|
||||
fun String.toSlug() = lowercase(Locale.getDefault())
|
||||
.replace("\n", " ")
|
||||
.replace("[^a-z\\d\\s]".toRegex(), " ")
|
||||
.split(" ")
|
||||
@@ -464,7 +470,7 @@ With Gradle:
|
||||
----
|
||||
plugins {
|
||||
...
|
||||
kotlin("plugin.allopen") version "1.4.32"
|
||||
kotlin("plugin.allopen") version "1.6.21"
|
||||
}
|
||||
|
||||
allOpen {
|
||||
@@ -908,7 +914,7 @@ To generate https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle
|
||||
----
|
||||
plugins {
|
||||
...
|
||||
kotlin("kapt") version "1.4.32"
|
||||
kotlin("kapt") version "1.6.21"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
plugins {
|
||||
id("org.springframework.boot") version "2.4.4"
|
||||
id("org.springframework.boot") version "2.7.1"
|
||||
id("io.spring.dependency-management") version "1.0.11.RELEASE"
|
||||
kotlin("jvm") version "1.4.32"
|
||||
kotlin("plugin.spring") version "1.4.32"
|
||||
kotlin("plugin.allopen") version "1.4.32"
|
||||
kotlin("plugin.jpa") version "1.4.32"
|
||||
kotlin("kapt") version "1.4.32"
|
||||
kotlin("jvm") version "1.6.21"
|
||||
kotlin("plugin.spring") version "1.6.21"
|
||||
kotlin("plugin.allopen") version "1.6.21"
|
||||
kotlin("plugin.jpa") version "1.6.21"
|
||||
kotlin("kapt") version "1.6.21"
|
||||
}
|
||||
|
||||
group = "com.example"
|
||||
@@ -34,13 +34,12 @@ dependencies {
|
||||
}
|
||||
testImplementation("org.junit.jupiter:junit-jupiter-api")
|
||||
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine")
|
||||
testImplementation("com.ninja-squad:springmockk:3.0.1")
|
||||
testImplementation("com.ninja-squad:springmockk:3.1.1")
|
||||
}
|
||||
|
||||
tasks.withType<KotlinCompile> {
|
||||
kotlinOptions {
|
||||
freeCompilerArgs = listOf("-Xjsr305=strict")
|
||||
jvmTarget = "1.8"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
6
pom.xml
6
pom.xml
@@ -14,7 +14,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-parent</artifactId>
|
||||
<version>2.4.4</version>
|
||||
<version>2.7.1</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||
<java.version>1.8</java.version>
|
||||
<kotlin.version>1.4.32</kotlin.version>
|
||||
<kotlin.version>1.6.21</kotlin.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
@@ -84,7 +84,7 @@
|
||||
<dependency>
|
||||
<groupId>com.ninja-squad</groupId>
|
||||
<artifactId>springmockk</artifactId>
|
||||
<version>3.0.1</version>
|
||||
<version>3.1.1</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -5,7 +5,7 @@ import java.time.format.DateTimeFormatterBuilder
|
||||
import java.time.temporal.ChronoField
|
||||
import java.util.*
|
||||
|
||||
fun LocalDateTime.format() = this.format(englishDateFormatter)
|
||||
fun LocalDateTime.format(): String = this.format(englishDateFormatter)
|
||||
|
||||
private val daysLookup = (1..31).associate { it.toLong() to getOrdinal(it) }
|
||||
|
||||
@@ -25,9 +25,9 @@ private fun getOrdinal(n: Int) = when {
|
||||
else -> "${n}th"
|
||||
}
|
||||
|
||||
fun String.toSlug() = toLowerCase()
|
||||
.replace("\n", " ")
|
||||
.replace("[^a-z\\d\\s]".toRegex(), " ")
|
||||
.split(" ")
|
||||
fun String.toSlug() = lowercase(Locale.getDefault())
|
||||
.replace("\n", " ")
|
||||
.replace("[^a-z\\d\\s]".toRegex(), " ")
|
||||
.split(" ")
|
||||
.joinToString("-")
|
||||
.replace("-+".toRegex(), "-")
|
||||
|
||||
@@ -1,3 +1,6 @@
|
||||
blog.title=Blog
|
||||
blog.banner.title=Warning
|
||||
blog.banner.content=The blog will be down tomorrow.
|
||||
|
||||
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
|
||||
spring.jpa.properties.hibernate.globally_quoted_identifiers_skip_column_definitions = true
|
||||
|
||||
Reference in New Issue
Block a user