-
-
Notifications
You must be signed in to change notification settings - Fork 970
feat: Upgrade to Spring Boot 4.0.1 and Spring Framework 7.0.2 #15354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 8.0.x
Are you sure you want to change the base?
Conversation
Spring Boot 4 removed the spring-orm hibernate5 module and theme support. This commit adds the necessary Spring Framework classes to maintain compatibility with Grails 8. - Add Hibernate5 ORM support classes (HibernateTemplate, HibernateTransactionManager, etc.) - Add Theme support classes (ThemeResolver, ThemeSource, etc.) - Update LICENSE and NOTICE with Spring Framework attribution
- Remove checkstyle excludes from grails-data-hibernate5/core and grails-spring - Fix import ordering to follow Grails conventions - Replace tabs with 4 spaces - Remove multiple consecutive empty lines - Fix indentation issues - Remove unused imports - Add servlet-api and spring-webmvc dependencies to grails-spring
Replaces deprecated 'junit-platform-runner' with 'junit-platform-suite' in all build files and updates Spring Boot imports to match the new 4.x package structure. Also updates dependencies and import statements for Hibernate, MongoDB, and other modules to ensure compatibility with Spring Boot 4.x . Fixes some testcontainers dependencies and adds missing compileOnly dependencies for webmvc and autoconfigure modules where required.
Forces Groovy 4.x dependencies and sets the groovy.version property, overriding Spring Boot 4.0.1's default Groovy 5.0.3. These overrides are temporary until Grails 8 is compatible with Groovy 5.
Added 'spring-boot-mongodb' to grails-data-mongodb/boot-plugin and included 'spring-boot-web-server' and 'spring-boot-tomcat' as test dependencies in grails-web-boot. This improves modularity and ensures required Spring Boot components are explicitly declared.
Refactored import statements in test specs to use updated package paths for TomcatServletWebServerFactory, ConfigurableServletWebServerFactory, and AnnotationConfigServletWebServerApplicationContext. This aligns with changes in Spring Boot package structure.
Bumped the Spring Boot version from 3.5.10 to 4.0.1 and added the spring-boot-loader-tools dependency to the dependencies list.
Included 'org.springframework.boot:spring-boot-hibernate' as a compileOnly dependency in the build.gradle file to support Hibernate integration at compile time.
Replaces usage of HttpStatus.MOVED_TEMPORARILY with HttpStatus.FOUND for temporary redirects in ResponseRedirector and updates related test assertions. This aligns with the current HTTP status code naming conventions.
Changed import from org.springframework.boot.autoconfigure.security.SecurityProperties to org.springframework.boot.security.autoconfigure.SecurityProperties to reflect updated package structure.
Theme support (THEME_SOURCE_ATTRIBUTE, THEME_RESOLVER_ATTRIBUTE) was removed from DispatcherServlet in Spring Framework 7.0. Define the attribute names directly as constants to maintain compatibility. Also update AnnotationConfigServletWebServerApplicationContext import for Spring Boot 4 package relocation.
…lity Changes include: - Update auto-configuration class package paths for Spring Boot 4 module restructuring (DataSourceAutoConfiguration, ReactorAutoConfiguration moved to new packages) - Fix GrailsApplicationBuilder to use GenericWebApplicationContext instead of AnnotationConfigServletWebApplicationContext (removed in Spring Boot 4) - Update DefaultTransactionStatus constructor calls for Spring Framework 7 (now requires 8 parameters: transactionName and nested added) - Remove SecurityProperties.DEFAULT_FILTER_ORDER dependency (removed in Spring Boot 4) - Fix MappedInterceptor.matches() signature change (now takes request, not path/matcher) - Deprecate HandlerAdapter.getLastModified() (removed from interface in Spring Framework 7) - Add new getBeanProvider(ParameterizedTypeReference) method to MockApplicationContext - Add spring-boot-jdbc and spring-boot-hibernate test dependencies for Hibernate5 tests - Fix ambiguous method overloading in test for MockHttpServletRequest.setCharacterEncoding
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR upgrades Grails Core to Spring Boot 4.0.1 and Spring Framework 7.0.2, a major version bump that includes significant breaking changes. The upgrade involves updating package imports for relocated Spring Boot autoconfiguration classes, replacing removed Spring Framework APIs, vendoring deprecated theme support code from Spring Framework, and updating test dependencies across all modules.
Changes:
- Upgrade Spring Boot from 3.5.10 to 4.0.1 and Spring Framework to 7.0.2
- Update all package imports for relocated Spring Boot autoconfiguration modules
- Vendor Spring Framework theme support and Hibernate ORM support classes that were removed in Spring Framework 7.0
- Replace removed Spring APIs with updated alternatives (e.g.,
MappedInterceptor.matches(),DefaultTransactionStatusconstructor) - Update test dependencies from
junit-platform-runnertojunit-platform-suite - Update Testcontainers artifact names to new modular format
Reviewed changes
Copilot reviewed 124 out of 125 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| dependencies.gradle | Updates Spring Boot version from 3.5.10 to 4.0.1 |
| build.gradle | Adds Groovy version overrides to prevent Spring Boot 4.0.1's default Groovy 5.0.3 |
| grails-bom/build.gradle | Overrides Groovy version in BOM properties |
| grails-core/src/main/groovy/org/grails/compiler/injection/ApplicationClassInjector.groovy | Updates excluded autoconfiguration class paths |
| grails-core/src/main/groovy/grails/config/external/ExternalConfigRunListener.groovy | Updates ConfigurableBootstrapContext import path |
| grails-core/src/main/groovy/grails/boot/GrailsApp.groovy | Updates WebServerApplicationContext import path |
| grails-controllers/src/main/groovy/org/grails/plugins/web/controllers/ControllersAutoConfiguration.java | Updates multiple Spring Boot autoconfiguration imports |
| grails-web-common/src/main/groovy/org/grails/web/config/http/GrailsFilters.java | Removes SecurityProperties dependency, adds hardcoded DEFAULT_FILTER_ORDER constant |
| grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/mvc/UrlMappingsHandlerMapping.groovy | Updates MappedInterceptor.matches() method signature |
| grails-web-url-mappings/src/main/groovy/org/grails/web/mapping/mvc/UrlMappingsInfoHandlerAdapter.groovy | Deprecates getLastModified() method (removed from interface) |
| grails-web-url-mappings/src/main/groovy/grails/web/mapping/ResponseRedirector.groovy | Replaces MOVED_TEMPORARILY with FOUND constant |
| grails-testing-support-core/src/main/groovy/org/grails/testing/GrailsApplicationBuilder.groovy | Replaces AnnotationConfigServletWebApplicationContext with GenericWebApplicationContext |
| grails-test-suite-base/src/main/groovy/org/grails/support/MockApplicationContext.java | Adds getBeanProvider(ParameterizedTypeReference) method |
| grails-spring/src/main/java/org/springframework/* | Vendors deprecated Spring Framework theme support classes |
| grails-data-hibernate5/core/src/main/java/org/grails/orm/hibernate/support/hibernate5/* | Vendors Spring ORM Hibernate support classes removed in Spring Framework 7.0 |
| grails-data-hibernate5/core/src/test/groovy/grails/gorm/annotation/transactions/TransactionalTransformSpec.groovy | Updates DefaultTransactionStatus constructor calls with new signature |
| grails-data-hibernate5/boot-plugin/src/main/groovy/org/grails/datastore/gorm/boot/autoconfigure/HibernateGormAutoConfiguration.groovy | Updates DataSourceAutoConfiguration and HibernateJpaAutoConfiguration imports |
| grails-data-mongodb/boot-plugin/src/main/groovy/org/grails/datastore/gorm/mongodb/boot/autoconfigure/MongoDbGormAutoConfiguration.groovy | Updates MongoAutoConfiguration and MongoProperties imports |
| Multiple build.gradle files | Updates junit-platform-runner to junit-platform-suite and adds new Spring Boot module dependencies |
| Multiple test files | Updates Testcontainers artifact names and Hibernate validation constraint imports |
| LICENSE, NOTICE | Adds attribution for vendored Spring Framework code |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
This PR upgrades Grails Core to Spring Boot 4.0.1 and Spring Framework 7.0.2, bringing major framework updates and compatibility fixes.
This PR uses Groovy 4.0.x and Hibernate 5.6-jakarta, since work on Groovy 5 and Hibernate 7.2 is progressing on other branches.
This is the minimum amount required for Grails to run on Spring Boot 4 and Hibernate 5.6-jakarta
Key Changes
Breaking Changes in Spring Boot 4 / Spring Framework 7
Package Relocations (Spring Boot 4)
Spring Boot 4 restructured its autoconfigure modules. The following classes moved:
DataSourceAutoConfigurationorg.springframework.boot.autoconfigure.jdbcorg.springframework.boot.jdbc.autoconfigureReactorAutoConfigurationorg.springframework.boot.autoconfigure.reactororg.springframework.boot.reactor.autoconfigureHibernateJpaAutoConfigurationorg.springframework.boot.autoconfigure.orm.jpaorg.springframework.boot.hibernate.autoconfigureAnnotationConfigServletWebServerApplicationContextorg.springframework.boot.web.servlet.contextorg.springframework.boot.web.server.servlet.contextRemoved APIs
SecurityProperties.DEFAULT_FILTER_ORDER-100inGrailsFiltersAnnotationConfigServletWebApplicationContextGenericWebApplicationContextfor testingDispatcherServlettheme supportMappedInterceptor.matches(String, PathMatcher)matches(HttpServletRequest)HandlerAdapter.getLastModified()Constructor Changes (Spring Framework 7)
DefaultTransactionStatusnow requires 8 parameters (addedtransactionNameandnested)Files Changed
Core Module Updates
ApplicationClassInjector.groovy- Updated excluded auto-configuration class pathsGrailsApplicationCompilerAutoConfiguration.java- Updated DataSourceAutoConfiguration pathControllersAutoConfiguration.java- Import reorganization for new packagesGrailsFilters.java- Removed SecurityProperties dependency, added DEFAULT_FILTER_ORDER constantTesting Support
GrailsApplicationBuilder.groovy- Use GenericWebApplicationContext instead of AnnotationConfigServletWebApplicationContextMockApplicationContext.java- AddedgetBeanProvider(ParameterizedTypeReference)methodAbstractGrailsTagTests.groovy- Added static constants for removed theme attributesTransactionalTransformSpec.groovy- Updated DefaultTransactionStatus constructor callsDefaultUrlCreatorTests.groovy- Fixed ambiguous method overloading for setCharacterEncodingURL Mappings
UrlMappingsHandlerMapping.groovy- Updated MappedInterceptor.matches() call signatureUrlMappingsInfoHandlerAdapter.groovy- Deprecated getLastModified() methodBuild Configuration
grails-data-hibernate5/boot-plugin/build.gradle- Added spring-boot-jdbc and spring-boot-hibernate test dependenciesTest Status
Passing Tests
grails-data-mongodb-spring-boot:testgrails-test-examples-app2:integrationTestgrails-test-examples-geb:integrationTestgrails-test-examples-gorm:integrationTestgrails-test-examples-demo33:integrationTestgrails-test-examples-cache:integrationTestgrails-test-examples-datasources:integrationTestgrails-core:testgrails-web-common:testgrails-web-url-mappings:testgrails-controllers:testKnown Failing Tests (External Plugin Issue)
The following integration tests fail due to an incompatibility in the external
grails-spring-securityplugin (version 7.0.1-SNAPSHOT):grails-test-examples-app1:integrationTestgrails-test-examples-app3:integrationTestgrails-test-examples-exploded:integrationTestRoot Cause:
This is a compatibility issue in the
grails-spring-securityplugin that needs to be addressed in that repository separately. The plugin'sReflectionUtils.getApplication()method is missing or has changed signature.Action Required: The
grails-spring-securityplugin needs to be updated for Spring Boot 4 compatibility before these test examples can pass.