spring-security-mongo icon indicating copy to clipboard operation
spring-security-mongo copied to clipboard

SecurityContextService defined two times?

Open activey opened this issue 6 years ago • 3 comments

Hi,

While starting up my local app and using EnableSecurityMongo annotation I'm getting this error:

***************************
APPLICATION FAILED TO START
***************************

Description:

The bean 'securityContextService', defined in class path resource [uk/co/caeldev/springsecuritymongo/config/MongoConfiguration$SpringSecurityConfiguration.class], could not be registered. A bean with that name has already been defined in URL [jar:file:/home/lukaszg/.m2/repository/uk/co/caeldev/spring-security-mongo/3.0.2/spring-security-mongo-3.0.2.jar!/uk/co/caeldev/springsecuritymongo/services/SecurityContextService.class] and overriding is disabled.

Action:

Consider renaming one of the beans or enabling overriding by setting spring.main.allow-bean-definition-overriding=true

I've noticed you are defining SecurityContext service in two manners at once:

@Bean
    public SecurityContextService securityContextService() {
      return new SecurityContextService();
    }

and by annotating this class with Component annotation...

Any ideas?

Thanks in advance

activey avatar Apr 25 '19 18:04 activey

Hello,

I see you might be write. Depending on the spring version that config might be new. I would try by adding the config to your yml or property file and see if you still get that error.

In the meantime I will remove the annotation. No point of having it.

Cheers,

caelcs avatar Apr 25 '19 18:04 caelcs

:+1:

activey avatar Apr 25 '19 19:04 activey

having the same issue im using the version 3.0.2 how can i fix i? thanks

YEMEAC avatar Aug 01 '19 12:08 YEMEAC