From 2b42fa37360f5ba3e767ad55bd0e55d5ed4aaf63 Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Fri, 15 Jul 2022 12:49:25 +0100 Subject: [PATCH] Switch to Web Flow 3.0 Upgrade to Spring Framework 6 and change package imports from servlet to jakarta. Not yet working as there is no Tiles anymore. --- booking-mvc/pom.xml | 78 +++++++------------ .../webflow/samples/booking/Booking.java | 22 +++--- .../samples/booking/BookingDateRange.java | 4 +- .../booking/BookingDateRangeValidator.java | 4 +- .../samples/booking/BookingFlowHandler.java | 4 +- .../webflow/samples/booking/Hotel.java | 8 +- .../samples/booking/JpaBookingService.java | 4 +- .../webflow/samples/booking/User.java | 6 +- .../booking/config/DataAccessConfig.java | 2 +- .../config/DispatcherServletInitializer.java | 2 +- .../SecurityWebApplicationInitializer.java | 1 + .../samples/booking/config/WebMvcConfig.java | 19 +---- booking-mvc/src/main/resources/log4j2.xml | 1 + pom.xml | 21 ++--- 14 files changed, 75 insertions(+), 101 deletions(-) diff --git a/booking-mvc/pom.xml b/booking-mvc/pom.xml index 23b34aa..ab30257 100644 --- a/booking-mvc/pom.xml +++ b/booking-mvc/pom.xml @@ -52,21 +52,21 @@ - javax.servlet - javax.servlet-api + jakarta.servlet + jakarta.servlet-api ${servlet.version} provided - javax.servlet.jsp - jsp-api - 2.1 + jakarta.servlet.jsp + jakarta.servlet.jsp-api + ${jsp-api.version} provided - javax.servlet - jstl - 1.2 + jakarta.servlet.jsp.jstl + jakarta.servlet.jsp.jstl-api + ${jstl-api} @@ -76,50 +76,21 @@ org.thymeleaf - thymeleaf-spring4 - 2.1.5.RELEASE + thymeleaf-spring6 + 3.1.0.M1 org.thymeleaf.extras - thymeleaf-extras-tiles2-spring4 - 2.1.1.RELEASE - - - org.thymeleaf.extras - thymeleaf-extras-springsecurity4 - 2.1.2.RELEASE + thymeleaf-extras-springsecurity6 + 3.1.0.M1 + - - org.apache.tiles - tiles-core - ${tiles.version} - - - org.apache.tiles - tiles-api - ${tiles.version} - - - org.apache.tiles - tiles-template - ${tiles.version} - - - org.apache.tiles - tiles-servlet - ${tiles.version} - - - org.apache.tiles - tiles-jsp - ${tiles.version} - + --> org.hsqldb @@ -127,14 +98,25 @@ ${hsqldb.version} runtime + + org.hibernate + hibernate-core-jakarta + ${hibernate.version} + org.hibernate hibernate-entitymanager ${hibernate.version} + + + org.hibernate + hibernate-core + + - org.hibernate + org.hibernate.validator hibernate-validator ${hibernate-validator.version} @@ -212,16 +194,16 @@ org.apache.maven.plugins maven-compiler-plugin - 3.7.0 + 3.10.1 - 1.8 - 1.8 + 17 + 17 org.apache.maven.plugins maven-surefire-plugin - 2.20.1 + 2.22.2 junit:junit diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Booking.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Booking.java index dba0cf3..b13fc5d 100755 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Booking.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Booking.java @@ -7,17 +7,17 @@ import java.util.Calendar; import java.util.Date; import java.util.Set; -import javax.persistence.Basic; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.GenerationType; -import javax.persistence.Id; -import javax.persistence.ManyToOne; -import javax.persistence.Temporal; -import javax.persistence.TemporalType; -import javax.persistence.Transient; -import javax.validation.constraints.Future; -import javax.validation.constraints.NotNull; +import jakarta.persistence.Basic; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.GenerationType; +import jakarta.persistence.Id; +import jakarta.persistence.ManyToOne; +import jakarta.persistence.Temporal; +import jakarta.persistence.TemporalType; +import jakarta.persistence.Transient; +import jakarta.validation.constraints.Future; +import jakarta.validation.constraints.NotNull; import org.hibernate.validator.constraints.NotEmpty; import org.springframework.format.annotation.DateTimeFormat; diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRange.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRange.java index a5cad18..f9d4708 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRange.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRange.java @@ -5,8 +5,8 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -import javax.validation.Constraint; -import javax.validation.Payload; +import jakarta.validation.Constraint; +import jakarta.validation.Payload; @Constraint(validatedBy = BookingDateRangeValidator.class) @Target({ ElementType.TYPE, ElementType.METHOD, ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.PARAMETER }) diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRangeValidator.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRangeValidator.java index 716a40b..ee7c133 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRangeValidator.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingDateRangeValidator.java @@ -1,7 +1,7 @@ package org.springframework.webflow.samples.booking; -import javax.validation.ConstraintValidator; -import javax.validation.ConstraintValidatorContext; +import jakarta.validation.ConstraintValidator; +import jakarta.validation.ConstraintValidatorContext; public class BookingDateRangeValidator implements ConstraintValidator { diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingFlowHandler.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingFlowHandler.java index ae531e7..516e855 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingFlowHandler.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/BookingFlowHandler.java @@ -1,7 +1,7 @@ package org.springframework.webflow.samples.booking; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; import org.springframework.webflow.core.FlowException; import org.springframework.webflow.execution.FlowExecutionOutcome; diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Hotel.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Hotel.java index 3bdad77..57ecd29 100755 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Hotel.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/Hotel.java @@ -3,10 +3,10 @@ package org.springframework.webflow.samples.booking; import java.io.Serializable; import java.math.BigDecimal; -import javax.persistence.Column; -import javax.persistence.Entity; -import javax.persistence.GeneratedValue; -import javax.persistence.Id; +import jakarta.persistence.Column; +import jakarta.persistence.Entity; +import jakarta.persistence.GeneratedValue; +import jakarta.persistence.Id; /** * A hotel where users may book stays. diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java index c05c76c..851026c 100755 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/JpaBookingService.java @@ -2,8 +2,8 @@ package org.springframework.webflow.samples.booking; import java.util.List; -import javax.persistence.EntityManager; -import javax.persistence.PersistenceContext; +import jakarta.persistence.EntityManager; +import jakarta.persistence.PersistenceContext; import org.springframework.stereotype.Repository; import org.springframework.stereotype.Service; diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/User.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/User.java index f0f6bae..f05e00a 100755 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/User.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/User.java @@ -2,9 +2,9 @@ package org.springframework.webflow.samples.booking; import java.io.Serializable; -import javax.persistence.Entity; -import javax.persistence.Id; -import javax.persistence.Table; +import jakarta.persistence.Entity; +import jakarta.persistence.Id; +import jakarta.persistence.Table; /** * A user who can book hotels. diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DataAccessConfig.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DataAccessConfig.java index 53166aa..22bd9b1 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DataAccessConfig.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DataAccessConfig.java @@ -2,7 +2,7 @@ package org.springframework.webflow.samples.booking.config; import java.util.Collections; -import javax.persistence.EntityManagerFactory; +import jakarta.persistence.EntityManagerFactory; import javax.sql.DataSource; import org.springframework.context.annotation.Bean; diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DispatcherServletInitializer.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DispatcherServletInitializer.java index c86c1e0..a2749a2 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DispatcherServletInitializer.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/DispatcherServletInitializer.java @@ -1,6 +1,6 @@ package org.springframework.webflow.samples.booking.config; -import javax.servlet.Filter; +import jakarta.servlet.Filter; import org.springframework.web.filter.HiddenHttpMethodFilter; import org.springframework.web.servlet.support.AbstractAnnotationConfigDispatcherServletInitializer; diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityWebApplicationInitializer.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityWebApplicationInitializer.java index df49deb..f20d751 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityWebApplicationInitializer.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/SecurityWebApplicationInitializer.java @@ -7,4 +7,5 @@ import org.springframework.security.web.context.AbstractSecurityWebApplicationIn * the chain of Spring Security filters. */ public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer { + } diff --git a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java index e5a3138..c2b9958 100644 --- a/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java +++ b/booking-mvc/src/main/java/org/springframework/webflow/samples/booking/config/WebMvcConfig.java @@ -7,13 +7,11 @@ import org.springframework.web.servlet.config.annotation.DefaultServletHandlerCo import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry; import org.springframework.web.servlet.config.annotation.ViewControllerRegistry; -import org.springframework.web.servlet.config.annotation.ViewResolverRegistry; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; -import org.springframework.web.servlet.view.tiles3.TilesConfigurer; +import org.springframework.web.servlet.view.InternalResourceViewResolver; +import org.springframework.web.servlet.view.UrlBasedViewResolver; import org.springframework.webflow.mvc.servlet.FlowHandlerAdapter; import org.springframework.webflow.mvc.servlet.FlowHandlerMapping; -import org.springframework.webflow.mvc.view.AjaxUrlBasedViewResolver; -import org.springframework.webflow.mvc.view.FlowAjaxTiles3View; import org.springframework.webflow.samples.booking.BookingFlowHandler; @EnableWebMvc @@ -62,17 +60,8 @@ public class WebMvcConfig implements WebMvcConfigurer { } @Bean - public AjaxUrlBasedViewResolver viewResolver() { - AjaxUrlBasedViewResolver resolver = new AjaxUrlBasedViewResolver(); - resolver.setViewClass(FlowAjaxTiles3View.class); - return resolver; - } - - @Bean - public TilesConfigurer tilesConfigurer() { - TilesConfigurer configurer = new TilesConfigurer(); - configurer.setDefinitions("/WEB-INF/**/views.xml"); - return configurer; + public UrlBasedViewResolver viewResolver() { + return new InternalResourceViewResolver(); } } diff --git a/booking-mvc/src/main/resources/log4j2.xml b/booking-mvc/src/main/resources/log4j2.xml index f495463..bb09f49 100644 --- a/booking-mvc/src/main/resources/log4j2.xml +++ b/booking-mvc/src/main/resources/log4j2.xml @@ -7,6 +7,7 @@ + diff --git a/pom.xml b/pom.xml index f2f943f..d11d3d5 100644 --- a/pom.xml +++ b/pom.xml @@ -10,26 +10,29 @@ booking-mvc + 3.4 2.5.1 - 5.4.33.Final - 6.2.3.Final + 5.6.10.Final + 7.0.4.Final 2.2.3 - 9.4.48.v20220622 + 11.0.11 + 3.0.0 + 2.0.0 4.13.2 2.14.0 2.2.20 2.3.8 8.0 - 3.1.0 - 3.0.8 - 2.5.1.RELEASE + 5.0.0 + 3.0.0-SNAPSHOT @@ -37,7 +40,7 @@ org.springframework spring-framework-bom - 5.3.22 + 6.0.0-M5 pom import @@ -46,7 +49,7 @@ spring-security-bom pom import - 5.6.6 + 6.0.0-M5 org.slf4j @@ -56,7 +59,6 @@ -