Youcef LAIDANI
Youcef LAIDANI

Reputation: 59988

@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?

Upvotes: 51

Views: 50903

Answers (2)

vamshikrishna Goud
vamshikrishna Goud

Reputation: 1

From latest versions onwards we can use @EnableMethodSecurity

Check the documentation.

Instead of using prePostEnabled = true you can use

@EnableMethodSecurity(securedEnabled = true)

because by default it is false.

Upvotes: -1

Youcef LAIDANI
Youcef LAIDANI

Reputation: 59988

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;

Upvotes: 119

Related Questions