Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring security configuration using annotation configured beans

I'm attempting to configure spring security to use a service I implemented for authentication. My services and entity manager and all that are configured with annotations. I don't want to move all of the service, dao, and entity manager configuration into XML. How can I get the authentication-provider configuration to reference a service bean that is only configured through annotations?

Here is the configuration in the xml

<authentication-manager>
    <authentication-provider user-service-ref="userService" />
</authentication-manager>

And here is the definition of the service

@Configurable
@Service( value = "userService" )
public class UserServiceImpl
        extends BaseDataServiceAbstract<User, Long>
        implements UserService
{
like image 347
digitaljoel Avatar asked Sep 02 '26 22:09

digitaljoel


1 Answers

If you just add this to your XML:

<context:component-scan base-package="org.package.where.your.beans.are"/>

Spring should pick up all your annotation-configured beans and let you autowire them into the security configuration.

Reference:

like image 185
Sean Patrick Floyd Avatar answered Sep 05 '26 10:09

Sean Patrick Floyd



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!