Skip to content

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

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)

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
AnnotationConfigServletWebServerApplicationContext org.springframework.boot.web.servlet.context org.springframework.boot.web.server.servlet.context

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

Build Configuration

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

Test Status

Passing Tests

  • grails-data-mongodb-spring-boot:test
  • grails-test-examples-app2:integrationTest
  • grails-test-examples-geb:integrationTest
  • grails-test-examples-gorm:integrationTest
  • grails-test-examples-demo33:integrationTest
  • grails-test-examples-cache:integrationTest
  • grails-test-examples-datasources:integrationTest
  • grails-core:test
  • grails-web-common:test
  • grails-web-url-mappings:test
  • grails-controllers:test

Known Failing Tests (External Plugin Issue)

The following integration tests fail due to an incompatibility in the external grails-spring-security plugin (version 7.0.1-SNAPSHOT):

  • grails-test-examples-app1:integrationTest
  • grails-test-examples-app3:integrationTest
  • grails-test-examples-exploded:integrationTest

Root Cause:

groovy.lang.MissingMethodException: No signature of method: 
static grails.plugin.springsecurity.ReflectionUtils.getApplication() 
is applicable for argument types: () values: []

This is a compatibility issue in the grails-spring-security plugin that needs to be addressed in that repository separately. The plugin's ReflectionUtils.getApplication() method is missing or has changed signature.

Action Required: The grails-spring-security plugin needs to be updated for Spring Boot 4 compatibility before these test examples can pass.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

1 participant