Skip to content

The bean 'preFilterAuthorizationAdvisor', defined in class path resource could not be registered #13572

@bratkartoffel

Description

@bratkartoffel

Describe the bug
After upgrading to spring boot 3.1.2 (implicitly upgrading spring-security to 6.1.2), my applicatin no longer starts. The startup fails due to the following message:

Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.support.BeanDefinitionOverrideException: Invalid bean definition with name 'preFilterAuthorizationAdvisor' defined in class path resource [org/springframework/security/config/annotation/method/configuration/PrePostMethodSecurityConfiguration.class]: Cannot register bean definition [Root bean: class [org.springframework.security.config.annotation.method.configuration.PrePostMethodSecurityConfiguration]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null; factoryMethodName=preFilterAuthorizationMethodInterceptor; initMethodNames=null; destroyMethodNames=[(inferred)]; defined in class path resource [org/springframework/security/config/annotation/method/configuration/PrePostMethodSecurityConfiguration.class]] for bean 'preFilterAuthorizationAdvisor' since there is already [Root bean: class [org.springframework.security.config.annotation.method.configuration.PrePostMethodSecurityConfiguration]; scope=; abstract=false; lazyInit=null; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=null;

First reported here: spring-projects/spring-boot#36481

Downgrading to 6.1.1 works again.

To Reproduce

Expected behavior
The application startups up without errors.

Sample
See To Reproduce section

Thanks,
Simon

@paweleg fyi

Metadata

Metadata

Assignees

Labels

in: configAn issue in spring-security-configtype: bugA general bug

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions