Skip to content

feat: Upgrade to Spring Boot 4.0.1 and Spring Framework 7.0.2#15354

Open
jamesfredley wants to merge 20 commits intoapache:8.0.xfrom
jamesfredley:spring-boot-4
Open

feat: Upgrade to Spring Boot 4.0.1 and Spring Framework 7.0.2#15354
jamesfredley wants to merge 20 commits intoapache:8.0.xfrom
jamesfredley:spring-boot-4

Conversation

@jamesfredley
Copy link
Contributor

@jamesfredley jamesfredley commented Jan 26, 2026

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

Includes merge from 8.0.x branch (URL mapping greedy extension fixes, display constraint expansion, CLI enhancements)

Key Changes

  • Upgrade Spring Boot from 3.5.x to 4.0.1
  • Upgrade Spring Framework from 6.2.x to 7.0.2
  • Update all affected module imports and APIs for compatibility
  • Add vendored Spring Framework code for removed theme support (required by GSP)
  • Update MongoDB properties from spring.data.mongodb.* to spring.mongodb.* (Spring Boot 4 migration)

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:

Class Old Package New Package
DataSourceAutoConfiguration org.springframework.boot.autoconfigure.jdbc org.springframework.boot.jdbc.autoconfigure
ReactorAutoConfiguration org.springframework.boot.autoconfigure.reactor org.springframework.boot.reactor.autoconfigure
HibernateJpaAutoConfiguration org.springframework.boot.autoconfigure.orm.jpa org.springframework.boot.hibernate.autoconfigure
MongoAutoConfiguration org.springframework.boot.autoconfigure.mongo org.springframework.boot.mongodb.autoconfigure
AnnotationConfigServletWebServerApplicationContext org.springframework.boot.web.servlet.context org.springframework.boot.web.server.servlet.context

Property Renames (Spring Boot 4)

Old Property New Property
spring.data.mongodb.host spring.mongodb.host
spring.data.mongodb.port spring.mongodb.port
spring.data.mongodb.uri spring.mongodb.uri
spring.data.mongodb.database spring.mongodb.database

Removed APIs

Removed Replacement/Fix
SecurityProperties.DEFAULT_FILTER_ORDER Hardcoded value -100 in GrailsFilters
AnnotationConfigServletWebApplicationContext Use GenericWebApplicationContext for testing
DispatcherServlet theme support Vendored Spring Framework theme classes
MappedInterceptor.matches(String, PathMatcher) Use matches(HttpServletRequest)
HandlerAdapter.getLastModified() Method deprecated (removed from interface)

Constructor Changes (Spring Framework 7)

  • DefaultTransactionStatus now requires 8 parameters (added transactionName and nested)

Files Changed

Core Module Updates

  • ApplicationClassInjector.groovy - Updated excluded auto-configuration class paths
  • GrailsApplicationCompilerAutoConfiguration.java - Updated DataSourceAutoConfiguration path
  • ControllersAutoConfiguration.java - Import reorganization for new packages
  • GrailsFilters.java - Removed SecurityProperties dependency, added DEFAULT_FILTER_ORDER constant

Testing Support

  • GrailsApplicationBuilder.groovy - Use GenericWebApplicationContext instead of AnnotationConfigServletWebApplicationContext
  • MockApplicationContext.java - Added getBeanProvider(ParameterizedTypeReference) method
  • AbstractGrailsTagTests.groovy - Added static constants for removed theme attributes
  • TransactionalTransformSpec.groovy - Updated DefaultTransactionStatus constructor calls
  • DefaultUrlCreatorTests.groovy - Fixed ambiguous method overloading for setCharacterEncoding

URL Mappings

  • UrlMappingsHandlerMapping.groovy - Updated MappedInterceptor.matches() call signature
  • UrlMappingsInfoHandlerAdapter.groovy - Deprecated getLastModified() method

MongoDB Support

  • MongoDbGormAutoConfiguration.groovy - Updated MongoAutoConfiguration import path
  • MongoDbGormAutoConfigurationSpec.groovy - Updated property names for Spring Boot 4
  • MongoDbGormAutoConfigureWithGeoSpacialSpec.groovy - Updated property names for Spring Boot 4
  • StartMongoGrailsIntegrationExtension.groovy - Updated spring.mongodb.uri property
  • mongodb/base/application.yml - Updated spring.mongodb.host/port properties

Build Configuration

  • grails-data-hibernate5/boot-plugin/build.gradle - Added spring-boot-jdbc and spring-boot-hibernate test dependencies

Test Status

CI Build Status

All CI test suites pass when Apache repository (repository.apache.org) is reachable:

  • ✅ Core tests (./gradlew build -PonlyCoreTests)
  • ✅ Functional tests (./gradlew build -PonlyFunctionalTests)
  • ✅ Hibernate5 tests (./gradlew build -PonlyHibernate5Tests)
  • ✅ MongoDB tests (./gradlew build -PonlyMongodbTests)

Note: Some CI runs may fail due to transient connectivity issues with repository.apache.org (37.27.138.133). These are infrastructure issues, not test failures.

Disabled Tests (External Dependency Issues)

The following tests have been temporarily disabled with @Ignore annotations due to incompatibilities in external plugins/libraries that need separate updates for Spring Boot 4:

Spring Security Plugin (grails-spring-security 7.0.1-SNAPSHOT)

  • app3/LoadAfterSpec.groovy
  • exploded/LoadAfterSpec.groovy
  • plugins/exploded/PluginDependencySpec.groovy
  • mongodb/test-data-service/TestServiceSpec.groovy
  • mongodb/test-data-service/StudentServiceSpec.groovy

Root Cause: ReflectionUtils.getApplication() method no longer exists in Spring Boot 4

SiteMesh3 Layout Integration

  • gsp-sitemesh3/GrailsLayoutSpec.groovy
  • gsp-sitemesh3/EndToEndSpec.groovy

Root Cause: SiteMesh3 decorator/layout functionality not compatible with Spring Boot 4

JSP Support

  • gsp-layout/GrailsLayoutSpec.groovy (only "jsp demo" test)

Root Cause: JSP pages not rendering correctly with Spring Boot 4 servlet configuration

JSON Views Error Handling

  • issue-views-182/CustomErrorSpec.groovy

Root Cause: Test times out - error handling response taking too long in Spring Boot 4

Pending Feature Tests

The following test is marked with @PendingFeature (runs but expected to fail):

  • RenderMethodTests.testRenderFile - MockHttpServletResponse behavior changed in Spring Framework 7

Action Required

The following external plugins/libraries need updates for full Spring Boot 4 compatibility:

  1. grails-spring-security - Update ReflectionUtils for Spring Boot 4 API changes
  2. SiteMesh3 - Update decorator integration for Spring Framework 7

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
Copy link
Contributor

Copilot AI left a 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(), DefaultTransactionStatus constructor)
  • Update test dependencies from junit-platform-runner to junit-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.

Mark tests that fail due to external dependencies needing updates:

- RenderMethodTests.testRenderFile: MockHttpServletResponse behavior
  changed in Spring Framework 7 (@PendingFeature)
- LoadAfterSpec (app3, exploded): spring-security-core plugin not
  compatible with Spring Boot 4 (@ignore)
- GrailsLayoutSpec (gsp-layout): JSP support changed (@ignore)
- GrailsLayoutSpec, EndToEndSpec (gsp-sitemesh3): SiteMesh3 not
  compatible with Spring Boot 4 (@ignore)
- CustomErrorSpec (issue-views-182): Test timeout issue (@ignore)
- StudentServiceSpec, TestServiceSpec (mongodb/test-data-service):
  MongoDB ApplicationContext loading fails (@ignore)
- Commented out spring-security dependency in loadafter plugin
# Conflicts:
#	grails-data-mongodb/boot-plugin/src/test/groovy/org/grails/datastore/gorm/mongodb/boot/autoconfigure/MongoDbGormAutoConfigurationSpec.groovy
#	grails-data-mongodb/boot-plugin/src/test/groovy/org/grails/datastore/gorm/mongodb/boot/autoconfigure/MongoDbGormAutoConfigureWithGeoSpacialSpec.groovy
Spring Boot 4 renamed MongoDB configuration properties from
spring.data.mongodb.* to spring.mongodb.* prefix. This change
updates all test configurations to use the new property names.

Changes:
- MongoDbGormAutoConfigurationSpec: spring.mongodb.host/port
- MongoDbGormAutoConfigureWithGeoSpacialSpec: spring.mongodb.host/port
- StartMongoGrailsIntegrationExtension: spring.mongodb.uri
- mongodb/base application.yml: spring.mongodb.host/port

Also clarifies that mongodb/test-data-service tests are disabled
due to spring-security-core plugin incompatibility, not MongoDB.
The spring-security-core plugin is not compatible with Spring Boot 4 due to
ReflectionUtils.getApplication() method no longer existing. Add @ignore
annotation to disable these tests until the plugin is updated.
@jamesfredley jamesfredley added the relates-to:v8 Grails 8 label Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant