Skip to content

feat: Upgrade to Spring Boot 4.0.4 and Spring Framework 7.0.6#15354

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

feat: Upgrade to Spring Boot 4.0.4 and Spring Framework 7.0.6#15354
jamesfredley wants to merge 7 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.4 and Spring Framework 7.0.6, 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 (7.0.x/7.1.x merge-ups, deprecations, new grails-testing-support-http-client module, @CompileStatic tag lib support, DatabaseCleanup annotation inheritance, functional test migrations)

Key Changes

  • Upgrade Spring Boot from 3.5.x to 4.0.4
  • Upgrade Spring Framework from 6.2.x to 7.0.6
  • Update all affected module imports and APIs for compatibility
  • Add vendored Spring ORM code for removed Hibernate 5 integration classes (Spring 7 dropped Hibernate 5 support)
  • Remove Spring theme/JSP support (deprecated in Grails 7.1, see Deprecate Spring JSP theme support for removal in Grails 8.0.0 #15457)
  • Update MongoDB properties from spring.data.mongodb.* to spring.mongodb.* (Spring Boot 4 migration)

Detailed Change Inventory

Category Change Files
Vendored Spring ORM code Spring 7 removed Hibernate 5 ORM integration classes. Vendored HibernateTemplate, HibernateTransactionManager, HibernateOperations, LocalSessionFactoryBean, LocalSessionFactoryBuilder, SessionFactoryUtils, SessionHolder, etc. into grails-data-hibernate5 16 new files in grails-data-hibernate5/core/src/main/java/.../hibernate5/
Theme/JSP support removed Spring 7 removed theme support from DispatcherServlet. Rather than vendoring, theme/JSP support was deprecated in Grails 7.1 and removed here (#15457) GspAutoConfiguration, GrailsApplicationContext, GrailsWebApplicationContext, AbstractGrailsTagTests, related test files
Package relocations Updated imports for 6 autoconfigure classes that moved in Spring Boot 4 ApplicationClassInjector, GrailsApplicationCompilerAutoConfiguration, ControllersAutoConfiguration, GrailsFilters, MongoDbGormAutoConfiguration
MongoDB property renames spring.data.mongodb.* to spring.mongodb.* application.yml, StartMongoGrailsIntegrationExtension, MongoDB test specs
Removed API replacements SecurityProperties.DEFAULT_FILTER_ORDER replaced with hardcoded -100; AnnotationConfigServletWebApplicationContext replaced with GenericWebApplicationContext; MappedInterceptor.matches(String,PathMatcher) replaced with matches(HttpServletRequest) GrailsFilters, GrailsApplicationBuilder, UrlMappingsHandlerMapping
Constructor signature changes DefaultTransactionStatus now requires 8 params (added transactionName and nested) TransactionalTransformSpec
Deprecated method removal HandlerAdapter.getLastModified() removed from interface UrlMappingsInfoHandlerAdapter
LoaderImplementation removed LoaderImplementation enum removed in Spring Boot 4; related configuration removed GrailsGradlePlugin, boot-plugin configurations
Test support updates MockApplicationContext added getBeanProvider(ParameterizedTypeReference); AbstractGrailsTagTests added static constants for removed theme attributes MockApplicationContext.java, AbstractGrailsTagTests

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 Removed from Grails (deprecated in 7.1, see #15457)
MappedInterceptor.matches(String, PathMatcher) Use matches(HttpServletRequest)
HandlerAdapter.getLastModified() Method deprecated (removed from interface)
Spring ORM Hibernate 5 integration classes Vendored into grails-data-hibernate5
LoaderImplementation enum Removed from Spring Boot 4; related Grails configuration removed

Constructor Changes (Spring Framework 7)

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

Workarounds

Workaround Reason Impact
Vendored Spring Hibernate 5 ORM classes into grails-data-hibernate5 Spring 7 removed Hibernate 5 integration Required only for the Hibernate 5.6-jakarta path. Goes away when apps migrate to Hibernate 7.2
Hardcoded DEFAULT_FILTER_ORDER = -100 in GrailsFilters SecurityProperties.DEFAULT_FILTER_ORDER removed Fragile if Spring Security changes the default. Should use Spring Security's constant when security plugin is updated

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
  • GrailsGradlePlugin.groovy - Removed LoaderImplementation references

GSP / Theme Removal

  • GspAutoConfiguration.java - Removed theme resolver configuration
  • GrailsApplicationContext.java - Removed ThemeSource field, onRefresh(), getTheme()
  • GrailsWebApplicationContext.java - Removed ThemeSource import and interface (removed in Spring Framework 7)
  • Theme/JSP support removed per Deprecate Spring JSP theme support for removal in Grails 8.0.0 #15457 (deprecated in Grails 7.1)

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
  • grails-test-examples/hibernate5/spring-boot-hibernate/build.gradle - Added spring-boot-hibernate for package relocation

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.

Known Build Issues (WIP)

  • grails-data-mongodb-spring-boot test compilation - needs updated imports
  • ApplicationClassInjectorSpec - test expects old autoconfigure package path

Disabled Tests (External Plugin Incompatibilities)

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:

Test Plugin/Library Root Cause Action Needed
app3/LoadAfterSpec Spring Security 7.0.1-SNAPSHOT ReflectionUtils.getApplication() removed in Spring Boot 4 Update grails-spring-security plugin
exploded/LoadAfterSpec Spring Security Same as above Same
plugins/exploded/PluginDependencySpec Spring Security Same as above Same
mongodb/test-data-service/TestServiceSpec Spring Security Same as above Same
mongodb/test-data-service/StudentServiceSpec Spring Security Same as above Same
gsp-sitemesh3/GrailsLayoutSpec SiteMesh3 Decorator/layout not compatible with Spring Framework 7 Update SiteMesh3 integration
gsp-sitemesh3/EndToEndSpec SiteMesh3 Same as above Same
issue-views-182/CustomErrorSpec JSON Views Error handling response times out Debug timeout root cause
RenderMethodTests.testRenderFile (@PendingFeature) MockHttpServletResponse Behavior changed in Spring Framework 7 Update test expectations

Open Decisions

Decision Context Options
SiteMesh3 SiteMesh3 is incompatible with Spring 7 (a) Request update to SiteMesh3, (b) Replace with Grails-native layout mechanism
Micronaut Spring Current micronautPlatformVersion=4.9.2 pulls Micronaut Spring 5.x (targets Spring Boot 3.x) (a) Pin micronaut-spring-boot-starter:6.0.0-M1 for Spring Boot 4 compat, (b) Wait for Micronaut 5 stable release

Remaining Work

  • Fix grails-data-mongodb-spring-boot test compilation
  • Update ApplicationClassInjectorSpec for new autoconfigure package paths
  • Update grails-spring-security plugin for ReflectionUtils.getApplication() removal
  • Fix SiteMesh3 decorator integration for Spring Framework 7
  • Address JSON Views error handling timeout
  • Rework Bean Builder - Spring 7 drops XML configuration support (Spring 7 - XML configuration no longer supported #14915); the current BeanBuilder is backed by XML; needs programmatic bean registration
  • Evaluate Micronaut Spring 6.0.0-M1 for Spring Boot 4 Micronaut integration

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

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.

@jamesfredley jamesfredley added the relates-to:v8 Grails 8 label Feb 3, 2026
@jamesfredley jamesfredley changed the title feat: Upgrade to Spring Boot 4.0.1 and Spring Framework 7.0.2 feat: Upgrade to Spring Boot 4.0.3 and Spring Framework 7.0.5 Feb 26, 2026
@jamesfredley
Copy link
Contributor Author

jamesfredley commented Feb 26, 2026

micronaut-projects/micronaut-spring#782 might be a blocker for micronaut on Grails 8, since Spring removed the CLASSIC boot loader and there is not yet a version of micronaut-spring released for Spring Boot 4, but the current functional test do pass. There will likely be some additional effort to ensure the micronaut plugin fully functions.

https://github.com/micronaut-projects/micronaut-spring/releases/tag/v6.0.0-M1 - has Spring Boot 4.0.x

@jamesfredley jamesfredley changed the title feat: Upgrade to Spring Boot 4.0.3 and Spring Framework 7.0.5 feat: Upgrade to Spring Boot 4.0.4 and Spring Framework 7.0.6 Mar 20, 2026
# Conflicts:
#	dependencies.gradle
#	grails-data-hibernate5/grails-plugin/src/main/groovy/org/grails/plugin/hibernate/support/GrailsOpenSessionInViewInterceptor.java
#	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
@jamesfredley
Copy link
Contributor Author

Micronaut Spring Compatibility Note

For full Micronaut integration with Spring Boot 4, we should evaluate upgrading to Micronaut Spring 6.0.0-M1 which includes:

The current grails-micronaut module uses micronaut-spring-boot-starter via micronautPlatformVersion=4.9.2 (Micronaut Platform 4.x), which pulls in Micronaut Spring 5.x targeting Spring Boot 3.x. Micronaut Spring 6.0.0-M1 targets Micronaut 5.x milestones, so adopting it would require updating the Micronaut stack as well.

Recommendation: Evaluate Micronaut Spring 6.0.0-M1 once Micronaut 5 reaches a stable release, or pin io.micronaut.spring:micronaut-spring-boot-starter:6.0.0-M1 directly if Micronaut integration is tested and needed before then.

8.0.x Merge Status

Merged latest 8.0.x into this branch. Post-merge fixes applied:

  • Removed vendored Spring theme files reintroduced by merge (already removed in Deprecate Spring JSP theme support for removal in Grails 8.0.0 #15457)
  • Removed LoaderImplementation usage reintroduced by merge (removed in Spring Boot 4)
  • Removed theme references from GrailsApplicationContext reintroduced by merge
  • Added missing SessionFactoryUtils vendored import in GrailsOpenSessionInViewInterceptor
  • Added spring-boot-hibernate dependency for test example package relocation

Remaining: GrailsWebApplicationContext and grails-data-mongodb-spring-boot still reference removed Spring theme APIs and need the same treatment. Additionally, ApplicationClassInjectorSpec needs updating for the new autoconfigure package path.

The 8.0.x merge reintroduced several items that had been removed or
updated for Spring Boot 4 compatibility:

- Remove vendored Spring theme files (10 files) already removed by apache#15457
- Remove theme references from GrailsApplicationContext (ThemeSource,
  onRefresh, getTheme)
- Remove LoaderImplementation import and CLASSIC loader convention from
  GrailsGradlePlugin (removed in Spring Boot 4)
- Add missing SessionFactoryUtils vendored import in
  GrailsOpenSessionInViewInterceptor
- Add spring-boot-hibernate dependency for HibernateJpaAutoConfiguration
  package relocation in test example

Assisted-by: Claude Code <Claude@Claude.ai>
@testlens-app

This comment has been minimized.

@testlens-app

This comment has been minimized.

ThemeSource (org.springframework.ui.context.ThemeSource) was removed in
Spring Framework 7.0. GrailsWebApplicationContext imported and implemented
this interface, causing grails-web-core compilation failure and cascading
all downstream CI jobs.

Assisted-by: Claude Code <Claude@Claude.ai>
@testlens-app

This comment has been minimized.

Sort org.springframework imports alphabetically before the grails/org.grails
group to satisfy checkstyle ImportOrder rule.

Assisted-by: Claude Code <Claude@Claude.ai>
@testlens-app
Copy link

testlens-app bot commented Mar 21, 2026

✅ All tests passed ✅

🏷️ Commit: 62f8864
▶️ Tests: 613 executed
⚪️ Checks: 35/35 completed


Learn more about TestLens at testlens.app.

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.

2 participants