Question

@EnableGlobalMethodSecurity is deprecated in the new spring boot 3.0

I use Spring Boot 3.0, and when I work on security configuration, I get a warning that the @EnableGlobalMethodSecurity is deprecated.

@Configuration
@EnableWebSecurity
@AllArgsConstructor
@EnableGlobalMethodSecurity(prePostEnabled = true)
public class SecurityConfig {

With what do I replace can replace @EnableGlobalMethodSecurity in Spring boot 3.0?

 48  43028  48
1 Jan 1970

Solution

 105

You can use now:

@EnableMethodSecurity

Check the documentation

Note that you can avoid using prePostEnabled = true, because by default is true.

boolean prePostEnabled() default true;
boolean jsr250Enabled() default false;
boolean proxyTargetClass() default false;
2022-12-24

Solution

 105

You can use now:

@EnableMethodSecurity

Check the documentation

Note that you can avoid using prePostEnabled = true, because by default is true.

boolean prePostEnabled() default true;
boolean jsr250Enabled() default false;
boolean proxyTargetClass() default false;
2022-12-24