From 88ce0510c59ee244e1b6894ba8719a63e155afe1 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 19 Sep 2023 09:31:16 +0100 Subject: [PATCH 1/3] Update to latest versions --- pom.xml | 6 +++--- .../petclinic/owner/OwnerController.java | 6 +++--- .../petclinic/owner/PetController.java | 20 ++++++++++++------- .../petclinic/owner/VisitController.java | 12 +++++++---- .../system/CrashControllerAdvice.java | 3 ++- .../petclinic/system/WelcomeController.java | 3 ++- .../samples/petclinic/vet/VetController.java | 5 +++-- .../resources/templates/fragments/layout.html | 2 +- .../petclinic/vet/VetControllerTests.java | 17 +++++++++------- ...re.web.servlet.AutoConfigureWebMvc.imports | 1 + 10 files changed, 46 insertions(+), 29 deletions(-) create mode 100644 src/test/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc.imports diff --git a/pom.xml b/pom.xml index 6571f8a..2367a9b 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ org.springframework.boot spring-boot-starter-parent - 3.1.1 + 3.1.3 petclinic-htmx @@ -24,13 +24,13 @@ 5.2.3 4.7.0 - 1.9.2 + 1.9.5 0.9.8 0.8.8 0.0.11 0.0.39 - 2.0.1 + 3.0.0 diff --git a/src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java b/src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java index 18da9a2..7600246 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/OwnerController.java @@ -18,9 +18,6 @@ import java.util.List; import java.util.Map; -import io.github.wimdeblauwe.hsbt.mvc.HxRequest; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -36,6 +33,9 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.servlet.ModelAndView; +import io.github.wimdeblauwe.htmx.spring.boot.mvc.HxRequest; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; /** diff --git a/src/main/java/org/springframework/samples/petclinic/owner/PetController.java b/src/main/java/org/springframework/samples/petclinic/owner/PetController.java index 53fb81c..b76c704 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/PetController.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/PetController.java @@ -15,18 +15,24 @@ */ package org.springframework.samples.petclinic.owner; -import io.github.wimdeblauwe.hsbt.mvc.HxRequest; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; -import jakarta.validation.Valid; +import java.util.Collection; + import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.util.StringUtils; import org.springframework.validation.BindingResult; import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.*; - -import java.util.Collection; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.InitBinder; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import io.github.wimdeblauwe.htmx.spring.boot.mvc.HxRequest; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; /** * @author Juergen Hoeller diff --git a/src/main/java/org/springframework/samples/petclinic/owner/VisitController.java b/src/main/java/org/springframework/samples/petclinic/owner/VisitController.java index 8c32a8c..132dfd1 100644 --- a/src/main/java/org/springframework/samples/petclinic/owner/VisitController.java +++ b/src/main/java/org/springframework/samples/petclinic/owner/VisitController.java @@ -17,14 +17,18 @@ import java.util.Map; -import io.github.wimdeblauwe.hsbt.mvc.HxRequest; -import jakarta.servlet.http.HttpServletRequest; -import jakarta.servlet.http.HttpServletResponse; import org.springframework.stereotype.Controller; import org.springframework.validation.BindingResult; import org.springframework.web.bind.WebDataBinder; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.InitBinder; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import io.github.wimdeblauwe.htmx.spring.boot.mvc.HxRequest; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import jakarta.validation.Valid; /** diff --git a/src/main/java/org/springframework/samples/petclinic/system/CrashControllerAdvice.java b/src/main/java/org/springframework/samples/petclinic/system/CrashControllerAdvice.java index d0c2c3a..ac53f57 100644 --- a/src/main/java/org/springframework/samples/petclinic/system/CrashControllerAdvice.java +++ b/src/main/java/org/springframework/samples/petclinic/system/CrashControllerAdvice.java @@ -1,10 +1,11 @@ package org.springframework.samples.petclinic.system; -import io.github.wimdeblauwe.hsbt.mvc.HtmxRequest; import org.springframework.ui.Model; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; +import io.github.wimdeblauwe.htmx.spring.boot.mvc.HtmxRequest; + /** * Controller advice that returns a special fragment in case the request was coming from * HTMX. diff --git a/src/main/java/org/springframework/samples/petclinic/system/WelcomeController.java b/src/main/java/org/springframework/samples/petclinic/system/WelcomeController.java index 2d78c6e..11795f0 100644 --- a/src/main/java/org/springframework/samples/petclinic/system/WelcomeController.java +++ b/src/main/java/org/springframework/samples/petclinic/system/WelcomeController.java @@ -16,10 +16,11 @@ package org.springframework.samples.petclinic.system; -import io.github.wimdeblauwe.hsbt.mvc.HxRequest; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; +import io.github.wimdeblauwe.htmx.spring.boot.mvc.HxRequest; + @Controller class WelcomeController { diff --git a/src/main/java/org/springframework/samples/petclinic/vet/VetController.java b/src/main/java/org/springframework/samples/petclinic/vet/VetController.java index 64742e4..5d18bc8 100644 --- a/src/main/java/org/springframework/samples/petclinic/vet/VetController.java +++ b/src/main/java/org/springframework/samples/petclinic/vet/VetController.java @@ -17,8 +17,6 @@ import java.util.List; -import io.github.wimdeblauwe.hsbt.mvc.HxRequest; -import jakarta.servlet.http.HttpServletResponse; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageRequest; import org.springframework.data.domain.Pageable; @@ -28,6 +26,9 @@ import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; +import io.github.wimdeblauwe.htmx.spring.boot.mvc.HxRequest; +import jakarta.servlet.http.HttpServletResponse; + /** * @author Juergen Hoeller * @author Mark Fisher diff --git a/src/main/resources/templates/fragments/layout.html b/src/main/resources/templates/fragments/layout.html index b765141..039d806 100755 --- a/src/main/resources/templates/fragments/layout.html +++ b/src/main/resources/templates/fragments/layout.html @@ -93,7 +93,7 @@ - + diff --git a/src/test/java/org/springframework/samples/petclinic/vet/VetControllerTests.java b/src/test/java/org/springframework/samples/petclinic/vet/VetControllerTests.java index 282f608..0e317d3 100644 --- a/src/test/java/org/springframework/samples/petclinic/vet/VetControllerTests.java +++ b/src/test/java/org/springframework/samples/petclinic/vet/VetControllerTests.java @@ -16,6 +16,16 @@ package org.springframework.samples.petclinic.vet; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.BDDMockito.given; +import static org.springframework.samples.petclinic.htmx.HtmxTestUtils.toggleHtmx; +import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.content; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.model; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; +import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.view; + import org.assertj.core.util.Lists; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; @@ -29,13 +39,6 @@ import org.springframework.http.MediaType; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.ResultActions; -import org.springframework.test.web.servlet.request.MockMvcRequestBuilders; - -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.BDDMockito.given; -import static org.springframework.samples.petclinic.htmx.HtmxTestUtils.toggleHtmx; -import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.*; /** * Test class for the {@link VetController} diff --git a/src/test/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc.imports b/src/test/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc.imports new file mode 100644 index 0000000..2994466 --- /dev/null +++ b/src/test/resources/META-INF/spring/org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureWebMvc.imports @@ -0,0 +1 @@ +io.github.wimdeblauwe.htmx.spring.boot.mvc.HtmxMvcAutoConfiguration From 616439d3bdd2d96c0a9976b14b2484aff2f00128 Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 19 Sep 2023 13:18:06 +0100 Subject: [PATCH 2/3] Fix gradle build --- build.gradle | 6 +++++- gradle/wrapper/gradle-wrapper.properties | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index d0a34bf..33a052c 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,6 @@ plugins { id 'java' - id 'org.springframework.boot' version '3.0.4' + id 'org.springframework.boot' version '3.1.3' id 'io.spring.dependency-management' version '1.1.0' id 'org.graalvm.buildtools.native' version '0.9.20' } @@ -17,6 +17,8 @@ repositories { ext.webjarsFontawesomeVersion = "4.7.0" ext.webjarsBootstrapVersion = "5.2.3" +ext.htmxSpringBootThymeleafVersion = "3.0.0" +ext.htmxOrgVersion = "1.9.5" dependencies { implementation 'org.springframework.boot:spring-boot-starter-cache' @@ -26,9 +28,11 @@ dependencies { implementation 'org.springframework.boot:spring-boot-starter-validation' implementation 'javax.cache:cache-api' implementation 'jakarta.xml.bind:jakarta.xml.bind-api' + implementation "io.github.wimdeblauwe:htmx-spring-boot-thymeleaf:${htmxSpringBootThymeleafVersion}" runtimeOnly 'org.springframework.boot:spring-boot-starter-actuator' runtimeOnly "org.webjars.npm:bootstrap:${webjarsBootstrapVersion}" runtimeOnly "org.webjars.npm:font-awesome:${webjarsFontawesomeVersion}" + runtimeOnly "org.webjars.npm:htmx.org:${htmxOrgVersion}" runtimeOnly 'com.github.ben-manes.caffeine:caffeine' runtimeOnly 'com.h2database:h2' runtimeOnly 'com.mysql:mysql-connector-j' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 774fae8..84a0b92 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From d55b59f1079be07d8ddd4ec9e8cce8d2f4893b4f Mon Sep 17 00:00:00 2001 From: Dave Syer Date: Tue, 19 Sep 2023 13:41:08 +0100 Subject: [PATCH 3/3] Use java.version like in vanilla PetClinic --- pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 2367a9b..0627c18 100644 --- a/pom.xml +++ b/pom.xml @@ -223,8 +223,8 @@ ${project.build.sourceEncoding} ${project.reporting.outputEncoding} - ${maven.compiler.source} - ${maven.compiler.target} + ${java.version} + ${java.version}