Replace global method security with method security

MSAL

@EnableGlobalMethodSecurity and <global-method-security> are deprecated in favor of @EnableMethodSecurity and <method-security>, respectively. The new annotation and XML element activate Spring’s pre-post annotations by default and use AuthorizationManager internally.

org.openrewrite.java.spring.security5.ReplaceGlobalMethodSecurityWithMethodSecurityXml
mod run . --recipe=org.openrewrite.java.spring.security5.ReplaceGlobalMethodSecurityWithMethodSecurityXml

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Change XML tag name global-method-security to method-security
  2. Change XML attribute