From 34f5b487e82901421a27c5026c73faab67ede2e7 Mon Sep 17 00:00:00 2001 From: Antoine Rey Date: Sat, 28 Jan 2023 18:15:09 +0100 Subject: [PATCH] Upgrade to Spring Boot 3.0.2 and Java 17 --- .github/workflows/gradle-build.yml | 4 ++-- build.gradle.kts | 13 +++++++------ readme.md | 2 +- .../samples/petclinic/model/BaseEntity.kt | 8 ++++---- .../samples/petclinic/model/NamedEntity.kt | 4 ++-- .../samples/petclinic/model/Person.kt | 6 +++--- .../samples/petclinic/owner/Owner.kt | 6 +++--- .../samples/petclinic/owner/OwnerController.kt | 2 +- .../springframework/samples/petclinic/owner/Pet.kt | 2 +- .../samples/petclinic/owner/PetController.kt | 2 +- .../samples/petclinic/owner/PetType.kt | 4 ++-- .../samples/petclinic/owner/VisitController.kt | 2 +- .../samples/petclinic/vet/Specialty.kt | 4 ++-- .../springframework/samples/petclinic/vet/Vet.kt | 4 ++-- .../springframework/samples/petclinic/vet/Vets.kt | 2 +- .../samples/petclinic/visit/Visit.kt | 4 ++-- .../samples/petclinic/model/ValidatorTests.kt | 2 +- .../system/MockMvcValidationConfiguration.kt | 6 ++---- 18 files changed, 38 insertions(+), 39 deletions(-) diff --git a/.github/workflows/gradle-build.yml b/.github/workflows/gradle-build.yml index d962bb0d..f3f16b2a 100644 --- a/.github/workflows/gradle-build.yml +++ b/.github/workflows/gradle-build.yml @@ -16,10 +16,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: Set up JDK 11 + - name: Set up JDK 17 uses: actions/setup-java@v2 with: - java-version: '11' + java-version: '17' distribution: 'adopt' cache: gradle - name: Grant execute permission for gradlew diff --git a/build.gradle.kts b/build.gradle.kts index be938984..ef5d7ff4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,14 +4,14 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile description = "Kotlin version of the Spring Petclinic application" group = "org.springframework.samples" // Align with Spring Version -version = "2.7.4" +version = "3.0.2" -java.sourceCompatibility = JavaVersion.VERSION_1_8 +java.sourceCompatibility = JavaVersion.VERSION_17 plugins { - val kotlinVersion = "1.7.10" - id("org.springframework.boot") version "2.7.4" - id("io.spring.dependency-management") version "1.0.11.RELEASE" + val kotlinVersion = "1.7.22" + id("org.springframework.boot") version "3.0.2" + id("io.spring.dependency-management") version "1.1.0" id("com.google.cloud.tools.jib") version "3.1.4" kotlin("jvm") version kotlinVersion kotlin("plugin.spring") version kotlinVersion @@ -23,7 +23,7 @@ val fontAwesomeVersion = "4.7.0" tasks { withType { kotlinOptions { - jvmTarget = "1.8" + jvmTarget = "17" freeCompilerArgs = listOf("-Xjsr305=strict") } } @@ -47,6 +47,7 @@ dependencies { implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-thymeleaf") implementation("com.fasterxml.jackson.module:jackson-module-kotlin") + implementation("org.glassfish.jaxb:jaxb-runtime") implementation("javax.cache:cache-api") implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") implementation("org.jetbrains.kotlin:kotlin-reflect") diff --git a/readme.md b/readme.md index 39f8e516..2c90bdf6 100644 --- a/readme.md +++ b/readme.md @@ -7,7 +7,7 @@ This is a [Kotlin](https://kotlinlang.org/) version of the [spring-petclinic][] ## Technologies used * Language: Kotlin -* Core framework: Spring Boot 2 with Spring Framework 5 Kotlin support +* Core framework: Spring Boot 3 with Spring Framework 6 Kotlin support * Server: Apache Tomcat * Web framework: Spring MVC * Templates: Thymeleaf and Bootstrap 5 diff --git a/src/main/kotlin/org/springframework/samples/petclinic/model/BaseEntity.kt b/src/main/kotlin/org/springframework/samples/petclinic/model/BaseEntity.kt index d8901e2d..b99e76c5 100644 --- a/src/main/kotlin/org/springframework/samples/petclinic/model/BaseEntity.kt +++ b/src/main/kotlin/org/springframework/samples/petclinic/model/BaseEntity.kt @@ -16,10 +16,10 @@ package org.springframework.samples.petclinic.model import java.io.Serializable -import javax.persistence.GeneratedValue -import javax.persistence.GenerationType -import javax.persistence.Id -import javax.persistence.MappedSuperclass +import jakarta.persistence.GeneratedValue +import jakarta.persistence.GenerationType +import jakarta.persistence.Id +import jakarta.persistence.MappedSuperclass /** * Simple JavaBean domain object with an id property. Used as a base class for objects diff --git a/src/main/kotlin/org/springframework/samples/petclinic/model/NamedEntity.kt b/src/main/kotlin/org/springframework/samples/petclinic/model/NamedEntity.kt index 1c943320..a005ae48 100644 --- a/src/main/kotlin/org/springframework/samples/petclinic/model/NamedEntity.kt +++ b/src/main/kotlin/org/springframework/samples/petclinic/model/NamedEntity.kt @@ -15,8 +15,8 @@ */ package org.springframework.samples.petclinic.model -import javax.persistence.Column -import javax.persistence.MappedSuperclass +import jakarta.persistence.Column +import jakarta.persistence.MappedSuperclass /** diff --git a/src/main/kotlin/org/springframework/samples/petclinic/model/Person.kt b/src/main/kotlin/org/springframework/samples/petclinic/model/Person.kt index 22f20038..3440e2ef 100644 --- a/src/main/kotlin/org/springframework/samples/petclinic/model/Person.kt +++ b/src/main/kotlin/org/springframework/samples/petclinic/model/Person.kt @@ -16,9 +16,9 @@ package org.springframework.samples.petclinic.model -import javax.persistence.Column -import javax.persistence.MappedSuperclass -import javax.validation.constraints.NotEmpty +import jakarta.persistence.Column +import jakarta.persistence.MappedSuperclass +import jakarta.validation.constraints.NotEmpty /** * Simple JavaBean domain object representing an person. diff --git a/src/main/kotlin/org/springframework/samples/petclinic/owner/Owner.kt b/src/main/kotlin/org/springframework/samples/petclinic/owner/Owner.kt index a4320330..e6cf06aa 100644 --- a/src/main/kotlin/org/springframework/samples/petclinic/owner/Owner.kt +++ b/src/main/kotlin/org/springframework/samples/petclinic/owner/Owner.kt @@ -18,9 +18,9 @@ package org.springframework.samples.petclinic.owner import org.springframework.samples.petclinic.model.Person import java.util.* -import javax.persistence.* -import javax.validation.constraints.Digits -import javax.validation.constraints.NotEmpty +import jakarta.persistence.* +import jakarta.validation.constraints.Digits +import jakarta.validation.constraints.NotEmpty /** * Simple JavaBean domain object representing an owner. diff --git a/src/main/kotlin/org/springframework/samples/petclinic/owner/OwnerController.kt b/src/main/kotlin/org/springframework/samples/petclinic/owner/OwnerController.kt index b6ca1aa2..73cf9c39 100644 --- a/src/main/kotlin/org/springframework/samples/petclinic/owner/OwnerController.kt +++ b/src/main/kotlin/org/springframework/samples/petclinic/owner/OwnerController.kt @@ -24,7 +24,7 @@ import org.springframework.web.bind.annotation.GetMapping import org.springframework.web.bind.annotation.InitBinder import org.springframework.web.bind.annotation.PathVariable import org.springframework.web.bind.annotation.PostMapping -import javax.validation.Valid +import jakarta.validation.Valid /** * @author Juergen Hoeller diff --git a/src/main/kotlin/org/springframework/samples/petclinic/owner/Pet.kt b/src/main/kotlin/org/springframework/samples/petclinic/owner/Pet.kt index ef69fa5b..abc13224 100644 --- a/src/main/kotlin/org/springframework/samples/petclinic/owner/Pet.kt +++ b/src/main/kotlin/org/springframework/samples/petclinic/owner/Pet.kt @@ -21,7 +21,7 @@ import org.springframework.samples.petclinic.model.NamedEntity import org.springframework.samples.petclinic.visit.Visit import java.time.LocalDate import java.util.* -import javax.persistence.* +import jakarta.persistence.* /** * Simple business object representing a owner. diff --git a/src/main/kotlin/org/springframework/samples/petclinic/owner/PetController.kt b/src/main/kotlin/org/springframework/samples/petclinic/owner/PetController.kt index d93b02b8..613e7b1a 100644 --- a/src/main/kotlin/org/springframework/samples/petclinic/owner/PetController.kt +++ b/src/main/kotlin/org/springframework/samples/petclinic/owner/PetController.kt @@ -23,7 +23,7 @@ import org.springframework.util.StringUtils import org.springframework.validation.BindingResult import org.springframework.web.bind.WebDataBinder import org.springframework.web.bind.annotation.* -import javax.validation.Valid +import jakarta.validation.Valid /** * @author Juergen Hoeller diff --git a/src/main/kotlin/org/springframework/samples/petclinic/owner/PetType.kt b/src/main/kotlin/org/springframework/samples/petclinic/owner/PetType.kt index 6285df2f..5e813eb9 100644 --- a/src/main/kotlin/org/springframework/samples/petclinic/owner/PetType.kt +++ b/src/main/kotlin/org/springframework/samples/petclinic/owner/PetType.kt @@ -17,8 +17,8 @@ package org.springframework.samples.petclinic.owner import org.springframework.samples.petclinic.model.NamedEntity; -import javax.persistence.Entity; -import javax.persistence.Table; +import jakarta.persistence.Entity; +import jakarta.persistence.Table; /** * @author Juergen Hoeller diff --git a/src/main/kotlin/org/springframework/samples/petclinic/owner/VisitController.kt b/src/main/kotlin/org/springframework/samples/petclinic/owner/VisitController.kt index e977bc4f..9e7f9ee9 100644 --- a/src/main/kotlin/org/springframework/samples/petclinic/owner/VisitController.kt +++ b/src/main/kotlin/org/springframework/samples/petclinic/owner/VisitController.kt @@ -21,7 +21,7 @@ import org.springframework.stereotype.Controller import org.springframework.validation.BindingResult import org.springframework.web.bind.WebDataBinder import org.springframework.web.bind.annotation.* -import javax.validation.Valid +import jakarta.validation.Valid /** * @author Juergen Hoeller diff --git a/src/main/kotlin/org/springframework/samples/petclinic/vet/Specialty.kt b/src/main/kotlin/org/springframework/samples/petclinic/vet/Specialty.kt index 2973862c..37aa2b88 100644 --- a/src/main/kotlin/org/springframework/samples/petclinic/vet/Specialty.kt +++ b/src/main/kotlin/org/springframework/samples/petclinic/vet/Specialty.kt @@ -16,8 +16,8 @@ package org.springframework.samples.petclinic.vet import org.springframework.samples.petclinic.model.NamedEntity -import javax.persistence.Entity -import javax.persistence.Table +import jakarta.persistence.Entity +import jakarta.persistence.Table /** * Models a {@link Vet Vet's} specialty (for example, dentistry). diff --git a/src/main/kotlin/org/springframework/samples/petclinic/vet/Vet.kt b/src/main/kotlin/org/springframework/samples/petclinic/vet/Vet.kt index 7b044548..e08f6e3f 100644 --- a/src/main/kotlin/org/springframework/samples/petclinic/vet/Vet.kt +++ b/src/main/kotlin/org/springframework/samples/petclinic/vet/Vet.kt @@ -16,8 +16,8 @@ package org.springframework.samples.petclinic.vet import org.springframework.samples.petclinic.model.Person -import javax.persistence.* -import javax.xml.bind.annotation.XmlElement +import jakarta.persistence.* +import jakarta.xml.bind.annotation.XmlElement /** * Simple JavaBean domain object representing a veterinarian. diff --git a/src/main/kotlin/org/springframework/samples/petclinic/vet/Vets.kt b/src/main/kotlin/org/springframework/samples/petclinic/vet/Vets.kt index 1db62f58..89222d72 100644 --- a/src/main/kotlin/org/springframework/samples/petclinic/vet/Vets.kt +++ b/src/main/kotlin/org/springframework/samples/petclinic/vet/Vets.kt @@ -15,7 +15,7 @@ */ package org.springframework.samples.petclinic.vet -import javax.xml.bind.annotation.XmlRootElement +import jakarta.xml.bind.annotation.XmlRootElement /** * Simple domain object representing a list of veterinarians. Mostly here to be used for the 'vets' [ ]. diff --git a/src/main/kotlin/org/springframework/samples/petclinic/visit/Visit.kt b/src/main/kotlin/org/springframework/samples/petclinic/visit/Visit.kt index e07f5a57..8a6217ac 100644 --- a/src/main/kotlin/org/springframework/samples/petclinic/visit/Visit.kt +++ b/src/main/kotlin/org/springframework/samples/petclinic/visit/Visit.kt @@ -18,8 +18,8 @@ package org.springframework.samples.petclinic.visit import org.springframework.format.annotation.DateTimeFormat import org.springframework.samples.petclinic.model.BaseEntity import java.time.LocalDate -import javax.persistence.* -import javax.validation.constraints.NotEmpty +import jakarta.persistence.* +import jakarta.validation.constraints.NotEmpty /** * Simple JavaBean domain object representing a visit. diff --git a/src/test/kotlin/org/springframework/samples/petclinic/model/ValidatorTests.kt b/src/test/kotlin/org/springframework/samples/petclinic/model/ValidatorTests.kt index 9d1836ac..c656f22b 100644 --- a/src/test/kotlin/org/springframework/samples/petclinic/model/ValidatorTests.kt +++ b/src/test/kotlin/org/springframework/samples/petclinic/model/ValidatorTests.kt @@ -6,7 +6,7 @@ import org.junit.jupiter.api.Test import org.springframework.context.i18n.LocaleContextHolder import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean import java.util.* -import javax.validation.Validator +import jakarta.validation.Validator /** * @author Michael Isvy diff --git a/src/test/kotlin/org/springframework/samples/petclinic/system/MockMvcValidationConfiguration.kt b/src/test/kotlin/org/springframework/samples/petclinic/system/MockMvcValidationConfiguration.kt index e9cc7375..318bf262 100644 --- a/src/test/kotlin/org/springframework/samples/petclinic/system/MockMvcValidationConfiguration.kt +++ b/src/test/kotlin/org/springframework/samples/petclinic/system/MockMvcValidationConfiguration.kt @@ -4,11 +4,9 @@ import org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorContro import org.springframework.boot.web.servlet.error.ErrorController import org.springframework.web.bind.annotation.ControllerAdvice import org.springframework.web.bind.annotation.ExceptionHandler -import org.springframework.web.bind.annotation.RequestMapping -import org.springframework.web.bind.annotation.ResponseBody import org.springframework.web.servlet.ModelAndView -import javax.servlet.http.HttpServletRequest -import javax.servlet.http.HttpServletResponse +import jakarta.servlet.http.HttpServletRequest +import jakarta.servlet.http.HttpServletResponse /** * This advice is necessary because MockMvc is not a real servlet environment, therefore it does not redirect error