Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 16, 2026

Spring Boot 4.0.1 removed/relocated several classes and APIs, causing compilation failures in configuration and test classes.

Configuration Changes

DatabaseStartupConfig - Replaced removed EntityManagerFactoryDependsOnPostProcessor:

// Before: EntityManagerFactoryDependsOnPostProcessor (removed in 4.0)
@Bean
public static EntityManagerFactoryDependsOnPostProcessor databaseStartupDependency() {
    return new EntityManagerFactoryDependsOnPostProcessor("databaseStartupValidator");
}

// After: Custom BeanFactoryPostProcessor
@Bean
public static BeanFactoryPostProcessor entityManagerFactoryDependsOnPostProcessor() {
    return beanFactory -> {
        String[] beanNames = beanFactory.getBeanNamesForType(EntityManagerFactory.class);
        for (String beanName : beanNames) {
            beanFactory.getBeanDefinition(beanName).setDependsOn("databaseStartupValidator");
        }
    };
}

SecurityConfig - Removed deprecated AntPathRequestMatcher.antMatcher() static method:

// Before
.requestMatchers(antMatcher("/webjars/**")).permitAll()

// After  
.requestMatchers("/webjars/**").permitAll()

MethodSecurityConfig - Migrated from deprecated @EnableGlobalMethodSecurity to @EnableMethodSecurity:

// Before
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class MethodSecurityConfig extends GlobalMethodSecurityConfiguration {
    @Override
    protected MethodSecurityExpressionHandler createExpressionHandler() { ... }
}

// After
@EnableMethodSecurity
public class MethodSecurityConfig {
    @Bean
    public MethodSecurityExpressionHandler methodSecurityExpressionHandler() { ... }
}

Test Changes

WebTest - Updated @AutoConfigureMockMvc import to new modular package:

// Before: org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc
// After:  org.springframework.boot.webmvc.test.autoconfigure.AutoConfigureMockMvc

Dependencies:

  • Added spring-boot-starter-webmvc-test (required for modular test support in 4.0)
  • Updated springdoc-openapi-starter-webmvc-ui to 3.0.0

Known Issue

WebTest has 4 failures due to springdoc-openapi 3.0.0 incompatibility with Spring Boot 4.0's restructured HATEOAS autoconfiguration. Main application code compiles and runs successfully.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

- Update DatabaseStartupConfig to use BeanFactoryPostProcessor for EntityManagerFactory dependency
- Update SecurityConfig to remove deprecated AntPathRequestMatcher.antMatcher() calls
- Update MethodSecurityConfig to use @EnableMethodSecurity instead of deprecated @EnableGlobalMethodSecurity
- Update WebTest to import AutoConfigureMockMvc from new package
- Add spring-boot-starter-webmvc-test dependency
- Update springdoc-openapi to 3.0.0 for Spring Boot 4.0 compatibility

Co-authored-by: ato <[email protected]>
Copilot AI changed the title [WIP] Update spring.version from 3.5.7 to 4.0.1 Fix Spring Boot 4.0.1 compatibility issues Jan 16, 2026
Copilot AI requested a review from ato January 16, 2026 08:47
@ato ato marked this pull request as ready for review January 16, 2026 08:47
@ato ato merged commit 2c8cda6 into dependabot/maven/spring.version-4.0.1 Jan 16, 2026
1 check passed
@ato ato deleted the copilot/sub-pr-180 branch January 16, 2026 08:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants